jwu has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have this strange question while doing some multi-threaded programming.
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(); }
Back to
Seekers of Perl Wisdom