in reply to Re^3: Annoying threads share problem!
in thread Annoying threads share problem!
I haven't gotten it reliably working either way, can you give a working example?Well, it depends rather on what exactly you are referring to as it, but
use threads; use threads::shared; sub X::DESTROY { warn "X::DESTROY(@_)\n" } my $x = bless [], 'X'; share $x; $x->[0] = 1; sub f { $x->[0]++; warn "x->[0] = $x->[0]\n"; } threads->new(\&f)->join for 1..5; __END__ $ perl587t /tmp/p x->[0] = 2 X::DESTROY(X=ARRAY(0x9d8b218)) x->[0] = 3 X::DESTROY(X=ARRAY(0x9da0500)) x->[0] = 4 X::DESTROY(X=ARRAY(0x9da0500)) x->[0] = 5 X::DESTROY(X=ARRAY(0x9da0500)) x->[0] = 6 X::DESTROY(X=ARRAY(0x9da0500)) X::DESTROY(X=ARRAY(0x9cd3c30))
Dave.
|
|---|