RosettaCodeData/Task/Concurrent-computing/Phix/concurrent-computing.phix

17 lines
399 B
Text
Raw Permalink Normal View History

2026-02-01 16:33:20 -08:00
without js -- (threads)
procedure echo(string s)
sleep(rand(100)/100)
enter_cs()
puts(1,s)
puts(1,'\n')
leave_cs()
end procedure
2023-07-01 11:58:00 -04:00
2026-02-01 16:33:20 -08:00
constant threads = {create_thread(routine_id("echo"),{"Enjoy"}),
create_thread(routine_id("echo"),{"Rosetta"}),
create_thread(routine_id("echo"),{"Code"})}
2023-07-01 11:58:00 -04:00
2026-02-01 16:33:20 -08:00
wait_thread(threads)
puts(1,"done")
{} = wait_key()