in reply to Re^10: Scope of thread variable
in thread Scope of thread variable

In your loop, you assign the return value from threads->create to a variable. What do you then do with that variable?

Replies are listed 'Best First'.
Re^12: Scope of thread variable
by mr_p (Scribe) on Apr 08, 2010 at 18:13 UTC
    This is what I meant:
    # some code here.... for (0 ..3)) { my $thr = threads->create ( sub { worker(); } )->detach(); } # Master Thread while (1) { master(); } sub master { while (1) { #check if workers are alive #enqueue work # .... } } sub worker { while (1) { #dequeue work # .... } }

    How can master() function monitor the threads that were created?