The following does not appear to run in concurrent threads as I expected, but rather each process blocks until it is complete:
my @arr = (1,2,3,4);
foreach (@arr) {
threads->new(\&doSomething, $_)->join;
}
sub doSomething {
my $thread = shift;
print "thread $thread\n";
sleep(5);
}
In other words, it appears to be executing the same as the non-threaded version would:
my @arr = (1,2,3,4);
foreach (@arr) {
doSomething($_);
}
I am running ActivePerl v5.10.1 mswin32-x86-multi-thread
How to I run concurrent threads in perl?