while( @threads ) { foreach (@threads) { if ( ( $_ -> is_joinable) { $_->join(); } } }