Let us define a word for the thread workload
-{ $code ": print-a-line ( i -- ) star-wars get ?nth print ;" }
+{ $code "
+: print-a-line ( i -- )
+ star-wars get ?nth print ;" }
If we give the i-th thread the name "\"i\"" , our example amounts to
It turns out that { $link sleep } does exactly what we need, but it takes a { $strong "duration" } object as input. We can create a
duration of i seconds with... well { $snippet "i seconds" } . So we define
-{ $code ": wait-and-print ( i -- ) dup seconds sleep print-a-line ;" }
+{ $code "
+: wait-and-print ( i -- )
+ dup seconds sleep print-a-line ;" }
Let us try