Reputation: 205
I have a Perl program. Everything is working fine, but I am seeing the errors below. I have also joined threads in the end, and tried checking is_joinable
, but nothing is working. This error is not causing any issue at the moment but I want to fix it
Perl exited with active threads:
6 running and unjoined
0 finished and unjoined
0 running and detached
my @threads;
open FILE, "$inputCsv" or die $!;
my @records = <FILE>;
foreach $record ( @records ) {
@fields = split( /,/, $record );
$identityDomain = $fields[0];
push( @threads, threads->new( \&populateSubscriptionMap, $identityDomain ) );
}
foreach $thr ( @threads ) {
print "threads - " . $thr;
my %myhash = $thr->join();
}
I have spent almost 3 hours on this and tried various things. I would appreciate if someone can take a look and help me out.
Upvotes: 1
Views: 2167
Reputation: 386551
$_->join() for threads->list();
is a simple way of waiting for all threads to end, but your problem is far more likely to be that you don't actually reach the part of your code that reaps the threads. The most likely culprits are:
exit
.Upvotes: 4