#! perl -slw use 5.012_000; use strict; use threads; use Data::Dumper; my %toc; for my $i (1..3) { my $id = async { sleep 3*$i+5; $i }; print Dumper($id); $toc{$id} = "starting thread $id, with \$i = $i"; } print Dumper(\%toc); sub joinable { threads->list( threads::joinable ) }; sub running { threads->list( threads::running ) }; while (my $count = scalar running) { sleep 1 until joinable; print "$toc{$_} => ", $_->join, "\n" for joinable; } print "all post-commands are complete\n";