2
我已經尋找相關的話題,但仍不能解決問題......如何在Perl中的線程之間共享對象?
use threads;
my $person = new Person('Name' => "yy");
my $udp_thread = threads->new(\&udp_func);
while(1)
{
$person->working();
}
sub udp_func
{
#Can't call method "setName" on an undefined value:
$person->setName();
}
我怎樣才能訪問對象$的人在新的線程?非常感謝!!
感謝您的幫助:)但是,可以線程::共享使線程之間共享的對象(這是動態更改)? – bluesea007 2009-11-10 08:43:21
也許這可能有幫助:http://perldoc.perl.org/threads/shared.html#OBJECTS – jonjbar 2009-11-10 10:24:00
非常感謝:)這個鏈接對我來說真的很有用:) – bluesea007 2009-11-11 08:18:38