#!/usr/bin/perl -w
use strict;
use threads;
sub thr {
print "Thread running.. Done.\n";
}
sub run_test {
my $x = bless {}, 'Obj';
threads->create(\&thr)->join();
}
sub Obj::DESTROY {
print "Destroyed from thread ", threads->tid, "\n";
}
run_test();
and the output:
Thread running.. Done.
Destroyed from thread 1
Destroyed from thread 0
So now I think that I don't know what I'm talking about.
Why did Perl copied the $x? it is not a global, and was not passed as parameter. I just don't get it.
If someone can point me to a relevant perldoc, I'll be greatefull.
thank, Shmuel. |