#! perl -slw use strict; use Time::HiRes qw[ sleep ]; use threads; use threads::shared; my @commands = map { my $t = 2+int( rand 5 ); qq[ perl -E"sleep 1 while ++\$n < $t" ]; } 1 .. 300; my $running :shared = 0; my $done :shared = 0; for my $cmd ( @commands ) { async{ ++$running; system $cmd; --$running; ++$done; }->detach; printf( "\r$done, $running" ), sleep 0.1 while $running > 2; }
In reply to Re: Implement Queue mechanism in Perl
by BrowserUk
in thread Implement Queue mechanism in Perl
by doubledecker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |