Skip to content

Instantly share code, notes, and snippets.

@ytnobody
Created February 27, 2013 02:16
Show Gist options
  • Save ytnobody/5044391 to your computer and use it in GitHub Desktop.
Save ytnobody/5044391 to your computer and use it in GitHub Desktop.
P::FMつかってみた
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