use strict; use threads; use threads::shared; use Thread::Pool; my $signal = undef; share($signal); my $fct = sub { require Blah; Blah->import(); $signal = 1; }; print "Starting the Thread::Pool\n"; my $pool = Thread::Pool->new( {do => $fct}); print "Thread::Pool started\n"; print "Sending a job to the Thread::Pool\n"; $pool->job(); print "Job sent to the Thread::Pool\n"; print "Waiting for the slave thread to set the shared signal\n"; while (!$signal) { print "Sleeping and waiting for signal from slave thread\n"; sleep(1); } print "Got shared signal from slave thread\n"; $pool->shutdown(); #### Starting the Thread::Pool #### Starting the Thread::Pool Thread::Pool started Sending a job to the Thread::Pool Job sent to the Thread::Pool Waiting for the slave thread to set the shared signal Sleeping and waiting for signal from slave thread Got shared signal from slave thread