|
Often times I have threads that do not finish after the join method is called. I thought join was supposed to wait for all threads to finish running.
When I create 9 threads I often get the following messages:
5 running and unjoined
4 finished and unjoined
0 running and detached
It skips 5 when that message comes back. If I get this message it is ok:
0 running and unjoined
9 finished and unjoined
0 running and detached
This is what the code looks like
for (1-10)
{
$thr=threads->create(\&func,$vars);
}
$thr->join();
Is there a way I can make join wait until all 10 threads finish? I would like to see the 2nd set of output statements every time it runs. Instead sometimes I get the first set which causes problems and other times I get the 2nd set which is ok. I need to ensure all threads ran properly before exiting.
I am using:
Perl v5.8.5
threads : 1.72
threads::shared : 0.92 |