Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming / Threads / Exercises / Run in a thread
Solution: Run in a thread
Here is a possible solution to the task.
Code
my $t = Thread.start({ say 'working' });
$t.finish;🦋 You can find the source code in the file run-in-thread.raku.
Output
workingComments
Thread.startruns the block on a new thread..finishwaits for the thread to complete, so the program does not end before42is printed.
Course navigation
← Run in a thread | Join and wait →