Concurrent computing: Difference between revisions

m
Updated code to match task, removed output as defined by task.
m (Updated code to match task, removed output as defined by task.)
m (Updated code to match task, removed output as defined by task.)
Line 1,295:
Using POSIX threads:
<lang Pike>int main() {
({
// Start threads and wait for them to finish
Thread.Thread(write, "Code\nA"),
({
Thread.Thread(write, "Enjoy\nB"),
Thread.Thread(write, "Rosetta\nC"),
}) -> wait();
Thread.Thread(write, "Code\n")
})->wait exit(0);
// Exit program
exit(0);
}</lang>
Output:
Enjoy
Rosetta
Code
 
Using Pike's backend:
<lang Pike>int main(int argc, array argv) {
call_out(write, random(1.0), "Code\nA");
{
call_out(write, random(1.0), "Enjoy\nB");
call_out(write, random(1.0), "Rosetta\nC");
call_out(write, random(1.0), "Code\n");
call_out(exit, 1, 0);
return -1;
return -1; // return -1 starts the backend which makes Pike run until exit() is called.
}</lang>
Output:
Rosetta
Code
Enjoy
 
=={{header|PowerShell}}==