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