Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Thanksuse warnings; use strict; use threads; use threads::shared; #use Time::HiRes; #my $t0 = Time::HiRes::time; my @array : shared; for (1..50) { push @array, $_; } my $thr = threads->create(\&spawnThread); my $thr2 = threads->create(\&spawnThread); my $thr3 = threads->create(\&spawnThread); my $thr4 = threads->create(\&spawnThread); my $thr5 = threads->create(\&spawnThread); $thr->join(); $thr2->join(); $thr3->join(); $thr4->join(); $thr5->join(); #my $t1 = Time::HiRes::time; #my $elapsed = $t1 - $t0; #print "\nElapsed Time: $elapsed\n"; sub spawnThread { for(1..10) { my $index = shift @array; print "$_ => $index\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Threads join vs detach
by liverpole (Monsignor) on Jan 26, 2007 at 16:22 UTC | |
|
Re: Threads join vs detach
by zentara (Cardinal) on Jan 26, 2007 at 17:04 UTC | |
|
Re: Threads join vs detach
by BrowserUk (Patriarch) on Jan 26, 2007 at 23:00 UTC |