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"; } }
In reply to Threads join vs detach by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |