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

Can you tell me how to use eval on this code?

To achieve what?

How can I restart thread a thread if it died with same thread Id?

You cannot. Thread ids are allocated by the system and are not re-used.

If you need a number within your threads that you assign, just pass it in as a parameter:

for my number (0 ..3)) { my $thr = threads->create ( sub { my $numberPassedIn = shift; worker(); }, $number )->detach(); }

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.
"I'd rather go naked than blow up my ass"

Replies are listed 'Best First'.
Re^6: Scope of thread variable
by mr_p (Scribe) on Apr 08, 2010 at 17:00 UTC
    How does the master thread know if worker threads are alive and well?
        How do I do that for forked threads?