multithreading - Getting Job id in do subroutine of Thread::Pool in Perl -
i not able job id inside subroutine thread::pool in perl. below code. can please me?
use strict; use warnings; use thread::pool; sub printnumbers( $ ) { $num = shift; $id = thread::pool->jobid; print "$id => $num\n"; } $pool = thread::pool->new( { optimize => 'cpu', => \&printnumbers, workers => 2, maxjobs => 4 } ); $pool->job( $_ ) foreach ( 1..100 ); $pool->shutdown;
i got answer.
instead of
$id = thread::pool->jobid;
add
$id = threads->tid();
and working correctly..
Comments
Post a Comment