my program is like:
use strict;
use threads;
use threads::shared;
my @thr;
for (my $i = 0; $i < $ARGV[0]; $i++) {
$thr[$i] = threads->create(\&Iteration, $i);
}
foreach (@thr) {
if ($_->is_running()) {
print "no";
}
else{
$_->join;
}
}
sub Iteration {
my $in = shift;
print "test$in\n";
}
But when I run it with $ARGV[0], say 5, the output is
test2
test1
test0
test3
test4
Can't locate auto/threads/is_running.al in @INC
So, how can I use the is_running() statement to check the status of one of my threads?
Looks right. That message indicates the sub doesn’t exist, so I suspect you are using an older version of threads, one that did not have such a method. If so, just upgrade your threads module.
The following should give you the version you have installed (current is 1.86,
is_runningappears to have been added to 1.34):The following should give you the documentation for the version you have installed: