You can't derive a coderef to a method because it wouldn't have its invocant. So pass a subref that invokes the method:
#!/usr/bin/perl use strict; use warnings; use threads; use myTest; my @threads; foreach ( 1..2 ) { print "launching job\n"; my $test = myTest->new(); push( @threads , threads->new( sub{ $test->myTestFunc } )); } foreach my $thread ( @threads ) { my @command_output = $thread->join ; print "job done\n"; } __END__ c:\test>t-junk2.pl launching job launching job doing job ... doing job ... job done job done
In reply to Re: thread on method
by BrowserUk
in thread thread on method
by lepetitalbert
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |