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.




Global mutex = CreateMutex()
 
Procedure Printer(*str)
	LockMutex(mutex)
	PrintN( PeekS(*str) )
	UnlockMutex(mutex)
EndProcedure
 
If OpenConsole()
	LockMutex(mutex)
	thread1 = CreateThread(@Printer(), @"Enjoy")
	thread2 = CreateThread(@Printer(), @"Rosetta")
	thread3 = CreateThread(@Printer(), @"Code")
	UnlockMutex(mutex)
 
	WaitThread(thread1)
	WaitThread(thread2)
	WaitThread(thread3)
 
	Print(#CRLF$ + #CRLF$ + "Press ENTER to exit")
	Input()
 
	CloseConsole()
EndIf
 
FreeMutex(mutex)