Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming / Threads / Exercises / Join and wait
Solution: Join and wait
Here is a possible solution to the task.
Code
my $t = Thread.start({ say 'first' });
$t.finish;
say 'second';🦋 You can find the source code in the file join-and-wait.raku.
Output
first
secondComments
.finishblocks until the thread has printedfirst.Only then does the main program continue and print
second, so the order is guaranteed. Without.finish, the two lines could appear in either order.
Course navigation
← Join and wait | Two threads →