Created
February 27, 2013 02:16
-
-
Save ytnobody/5044391 to your computer and use it in GitHub Desktop.
P::FMつかってみた
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Parallel::ForkManager; | |
my $pm = Parallel::ForkManager->new(4); | |
for my $i ( 1 .. 30 ) { | |
my $sleep = int(rand(5)+3); | |
my $pid = $pm->start and next; | |
printf "PID:%s NUM:%s START sleep %s\n", $pid, $i, $sleep; | |
sleep $sleep; | |
printf "PID:%s NUM:%s END\n", $pid, $i; | |
$pm->finish; | |
} | |
$pm->wait_all_children; | |
print "EXIT\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment