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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -