Perlについての質問箱 23箱目
■ このスレッドは過去ログ倉庫に格納されています
0516デフォルトの名無しさん
2006/04/05(水) 03:49:13共有するにはどのような手段があるでしょうか?
多段になっている配列やハッシュ変数の内容を子スレッド側で変えたいと思っています。
use strict;
use threads;
use threads::shared;
my @s : shared;
main();
sub main {
my $th = threads->new( \&thr );
$th->join;
print "in main: @s\n";
}
sub thr {
@s = ( 1, 2, 3 ); # OK
# @s = ( 1, [2, 3] ); # NG
print "in thr @s\n";
}
threads::shared のドキュメントを読んで、こういうことはできなそうだと分かったのですが、
スカラー変数などに詰め込んで渡して、親スレッド側で展開等しかないのでしょうか・・。
■ このスレッドは過去ログ倉庫に格納されています