Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: thread on method

by BrowserUk (Pope)
on Nov 24, 2009 at 05:07 UTC ( #808997=note: print w/replies, xml ) Need Help??


in reply to thread on method

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

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: thread on method
by lepetitalbert (Monsignor) on Nov 24, 2009 at 10:51 UTC

    Hi BrowserUk,

    Thanks a lot !

    Have a nice day.


    "There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://808997]
help
Chatterbox?
[LanX]: did you even go to the Dutch Perl Workshop in Utrecht?
[erix]: haha ok. I'm going to Glasgow though, and make a long road trip round the isles
[erix]: [Lanx} not the last time but the one before (there have been two)
[LanX]: when did you move to Utrecht, you used to live in a windmill on a dyke walking around in wooden shoes. ..
[LanX]: ... did you lie to me? OO
erix wouldn't mind a nice old windmill to live in... Mueller/Miller/ Molenaar

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2017-12-15 16:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (439 votes). Check out past polls.

    Notices?