What about declaring the variable shared before assigning it to your hash, as in my $var : shared = 1; $self->{var} = \$var. Although on further consideration I wonder if it might be better to be using a package variable via our or use vars since it looks like what you want is a 'static' variable i.e., one shared by all instances of a class, and these constructs provide that behavior. I don't have threads compiled so I can't test this, but this might work:
package OOThread; use threads; our static_var : shared = 1; # may not be necessary to explicitly shar +e 'our' variables sub new {...} ...
In reply to Re: Re: Re: OO and Threads conflict?
by djantzen
in thread OO and Threads conflict?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |