Patience is a virtue.
With problems of this nature you'd get a more (and faster) responses if you posted a runnable example. As is, you force anyone thinking of trying to help, to have to try to recreate the code that you already have sitting on your harddrive. Most won't bother. I tried and failed.
WIAT: Modifying your OP without attribution, such that it makes my initial response read as wrong, is not the best way to endear yourself.
I cannot find the discussion I remember concerning DESTROY methods and threads, despite several searches. However, it may not be applicable as I have a feeling that half-remembered discussion was XS related.
However, two possibilities come to mind:
use sshConnector; sub methodA { my $self = shift; my $count = shift; my $hostname; while ($count) { ($status,$hostname) = $self->cmd("hostname"); print "$count : $hostname\n"; sleep 1; $count--; } } sub methodB { my $self = shift; my $count = shift; my $hostname; while ($count) { ($status,$hostname) = $self->cmd("hostname"); print "$count : $hostname\n"; sleep 2; $count--; } } my $machine1 = new Connector($deviceInfo1); my $thr1 = threads->create('methodA',$machine1,10); my $machine2 = new Connector($deviceInfo2); my $thr2 = threads->create('methodB',$machine2,6); $thr1->join(); print "First thread over\n"; $thr2->join(); print "Second thread over\n";
Closures and threads have a history of bugs--many fixed--but still best avoided if possible.
my $machine1 :shared = new Connector($deviceInfo1); my $thr1 = threads->create('methodA',$machine1,10); my $machine2 :shared = new Connector($deviceInfo2); my $thr2 = threads->create('methodB',$machine2,6);
On the off-chance that the relatively recent changes that made it possible to shared blessed references also added some magic to ensure the appropriate ordering of destructors.
In reply to Re^5: Attempt to free non-existent shared string 'io_socket_type', Perl interpreter: 0x84972e0 during global destruction.
by BrowserUk
in thread Attempt to free non-existent shared string 'io_socket_type', Perl interpreter: 0x84972e0 during global destruction.
by madhurikl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |