while( @arrayRunningThreads ){
my @keepers;
for my $thread ( @arrayRunningThreads ){
if( $thread->is_joinable() ){
$thread ->join;
} elsif( not $thread ->is_detached ){
push @keepers, $thread;
}
}
@arrayRunningThreads = @keepers;
}
####
while( @arrayRunningThreads ){
my @keepers;
for my $thread ( @arrayRunningThreads ){
if( $thread->is_joinable() ){
$thread ->join;
} else {
push @keepers, $thread;
}
}
@arrayRunningThreads = @keepers;
}
####
for my $thread ( @arrayRunningThreads ){
$thread->join;
}