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.




int Key, Process;
[Key:= SharedMem(4);    \allocate 4 bytes of memory common to all processes
Process:= Fork(2);      \start 2 child processes
case Process of
  0:  [Lock(Key);  Text(0, "Enjoy");    CrLf(0);  Unlock(Key)]; \parent process
  1:  [Lock(Key);  Text(0, "Rosetta");  CrLf(0);  Unlock(Key)]; \child process
  2:  [Lock(Key);  Text(0, "Code");     CrLf(0);  Unlock(Key)]  \child process
other [Lock(Key);  Text(0, "Error");    CrLf(0);  Unlock(Key)];
Join(Process);          \wait for all child processes to finish
]