Concurrent computing: Difference between revisions

Content deleted Content added
Insert random delay
No edit summary
Line 342: Line 342:
(println Str) # Print string
(println Str) # Print string
(bye) ) ) ) # Terminate child process</lang>
(bye) ) ) ) # Terminate child process</lang>

=={{header|PureBasic}}==
<lang PureBasic>Global mutex.i
mutex = CreateMutex()

Procedure t_enjoy(dummy.i)
LockMutex(mutex)
PrintN("enjoy")
UnlockMutex(mutex)
EndProcedure
Procedure t_rosetta(dummy.i)
LockMutex(mutex)
PrintN("rosetta")
UnlockMutex(mutex)
EndProcedure
Procedure t_code(dummy.i)
LockMutex(mutex)
PrintN("code")
UnlockMutex(mutex)
EndProcedure

LockMutex(mutex)
OpenConsole()

thread1 = CreateThread(@t_enjoy(), 0)
thread2 = CreateThread(@t_rosetta(), 0)
thread3 = CreateThread(@t_code(), 0)

UnlockMutex(mutex)

WaitThread(thread1)
WaitThread(thread2)
WaitThread(thread3)

Input()

CloseConsole()

FreeMutex(mutex)</lang>


=={{header|Python}}==
=={{header|Python}}==