#! perl -slw use strict; use threads stack_size => 4096; use threads::Q; sub thread { my $Q = shift; while( my $item = $Q->dq ) { system qq[ doit.exe $item ]; } } our $T //= 20; my @ordered_arguments = ; chomp @ordered_arguments; my $Q = threads::Q->new( $T * 2 ); my @threads = map async( \&thread, $Q ), 1 .. $T; $Q->nq( $_ ) for @ordered_arguments; $Q->nq( (undef) x $T ); $_->join for @threads; __DATA__ ...