my $done :shared = 0; async{ $_->join for @threads; $done = 1; }->detach; sleep 1 until $done; exit 0;