Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Annoying threads share problem!

by castaway (Parson)
on Oct 09, 2005 at 13:46 UTC ( [id://498561]=note: print w/replies, xml ) Need Help??


in reply to Re^2: 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?

C.

Replies are listed 'Best First'.
Re^4: Annoying threads share problem!
by dave_the_m (Monsignor) on Oct 09, 2005 at 14:17 UTC
    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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-23 07:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found