Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Threads and object access

by djantzen (Priest)
on Dec 11, 2002 at 19:26 UTC ( #219152=note: print w/replies, xml ) Need Help??

in reply to Threads and object access

Disclaimer: this is based purely on reading, not real experience ;^)

The model of threading in 5.8, ithreads, completely separates variables created in one thread from those in other threads. Much like forked processes, ithreads duplicate data rather than share it unless explicitly told to do so. I believe the reason for this approach is due to a vast quantity of Perl code having been written without consideration for thread safety. ithreads separate data to prevent race conditions when multiple threads manipulate the same object.

So, I believe what you'll need to do is declare your variable $HS like:

use threads::shared; my $HS : shared; # compile time declaration $HS = new Something();
use threads::shared; $HS = new Something(); share($HS);

If this doesn't answer your question, perhaps you could post the relevant sections of code.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (1)
As of 2023-09-24 01:42 GMT
Find Nodes?
    Voting Booth?

    No recent polls found