in reply to Building a thread pool
Fire is up and watch those processors hummmm! Also the lighter weight version offered by browserUK in this thread worked well for me as posted. Thanks to you all. Barry#!/usr/bin/perl use strict; use warnings; use Thread::Pool; my $pool = Thread::Pool->new({workers => 10, do => \&do, monitor => \&monitor}); my @jobs = ('A' .. 'Z'); my $count; for (@jobs) { print $count++, "\n"; $pool->job($_); } sub do { my $letter = shift; print "begin: $letter\n"; for (1 .. 10000000) { my $x = $_ ^ 2; } print "end: $letter\n"; return "$letter is back\n\n"; } sub monitor {print shift}
|
|---|