http://qs1969.pair.com?node_id=1085017


in reply to What is the correct way to finish multithreaded program?

While I'm not an expert on threads, I believe this is the problem:

foreach my $thr (@threads) { if ( $thr->is_joinable() ) { $thr->join(); } }

You only join the threads that have already finished; instead you should join them all, i.e. wait for them to finish.