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