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.




#directory "+threads"
#load "unix.cma"
#load "threads.cma"
 
let sleepy_print msg =
  Unix.sleep (Random.int 4);
  print_endline msg
 
let threads =
  List.map (Thread.create sleepy_print) ["Enjoy"; "Rosetta"; "Code"]
 
let () =
  Random.self_init ();
  List.iter (Thread.join) threads