Task

Using either native language concurrency syntax or freely available libraries, write a program to display the strings "Enjoy" "Rosetta" "Code", one string per line, in random order.

Concurrency syntax must use threads, tasks, co-routines, or whatever concurrency is called in your language.




without js -- (threads)
procedure echo(string s)
    sleep(rand(100)/100)
    enter_cs()
    puts(1,s)
    puts(1,'\n')
    leave_cs()
end procedure
 
constant threads = {create_thread(routine_id("echo"),{"Enjoy"}),
                    create_thread(routine_id("echo"),{"Rosetta"}),
                    create_thread(routine_id("echo"),{"Code"})}
 
wait_thread(threads)
puts(1,"done")
{} = wait_key()
