Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Retreiving variables from threads

by zentara (Archbishop)
on Oct 29, 2005 at 11:27 UTC ( [id://503852]=note: print w/replies, xml ) Need Help??


in reply to Retreiving variables from threads

Usually it is a good idea to set the shared value too. This works for me.
use threads; use threads::shared; my %shash; my @choices; my $x; share $shash{'go'}; share @choices; share $x; $shash{'go'} = 0; @choices = ( ); $x = 1;
Also if you declare them as shared, after you initialize them, you will lose the initialization.

Another tip is the main thread will not automatically read the shared variable (like thru a reference). You may need to actively read it in the main thread.


I'm not really a human, but I play one on earth. flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://503852]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-25 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found