jwu has asked for the wisdom of the Perl Monks concerning the following question:
The code below output :
with two more DESTROY calls, how can I avoid them? I am using ActiveState 5.8.4 810 on Win XPthread start Destroy A=HASH(0x10124254) thread start Destroy A=HASH(0x101254f4) Destroy A=HASH(0x1002f054)
Also, if I use my $a : shared = A->new() then there will be another two more DESTROY calls.
Thanks.use threads; use threads::shared; { package A; use threads; use threads::shared; sub new { my $class = shift; my $self = &share({}); return bless $self, $class; } sub get_s { } sub DESTROY { print "Destroy $_[0]\n"; } } my $a = &share(A->new()); for (1..2) { async { print "thread start\n"; $a->get_s(); }->join(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to avoid extra DESTROY calls in multi-threaded program?
by renodino (Curate) on Dec 21, 2006 at 19:10 UTC | |
|
Re: How to avoid extra DESTROY calls in multi-threaded program?
by ivancho (Hermit) on Dec 21, 2006 at 18:23 UTC | |
|
Re: How to avoid extra DESTROY calls in multi-threaded program?
by SFLEX (Chaplain) on Dec 21, 2006 at 18:19 UTC | |
by chromatic (Archbishop) on Dec 21, 2006 at 19:09 UTC | |
by SFLEX (Chaplain) on Dec 21, 2006 at 19:13 UTC |