die "Shutting down pool while there are still jobs to be done"
if $belt->onbelt;
####
This is perl, v5.10.0 built for darwin-thread-multi-2leve
####
#!/usr/bin/perl
use Thread::Pool;
use strict;
use warnings;
sub my_process {
print "Hi i am a spawned sub and I am sleeping. my ID is $_[0]\n";
sleep(10);
}
my $pool = Thread::Pool->new({
workers => 2,
maxjobs => 1,
do => \&my_process
});
my ($i);
for($i=0;$i<10;$i++){ $pool->job($i); }
print "sleep for 5\n";
sleep(5);
print "will now abort\n";
$pool->abort();
print "will now shutdown\n";
$pool->shutdown();
print "all is normal but unfortunately i die before i come here\n";
exit(0);