이것은 내 코드입니다.오류 코드는 '스레드 1이 비정상적으로 종료되었습니다 : 공유 스칼라 값이 잘못되었습니다'
코드에 해시 공유에 대한 문제가 있습니다.
use strict;
use warnings;
use threads;
use threads::shared;
my %db;
share(%db);
my @threads;
sub test{
my $db_ref = $_[0];
my @arr = ('a','b');
push @{$db_ref->{'key'}}, \@arr;
}
foreach(1..2){
my $t = threads->new(
sub {
test(\%db);
}
);
push(@threads,$t);
}
foreach (@threads) {
$_->join;
}
오류 코드
Thread 1 terminated abnormally: Invalid value for shared scalar at test1.pl line 13.
Thread 2 terminated abnormally: Invalid value for shared scalar at test1.pl line 13.
나는 스레드를 사용 : 공유 waana.
그러나 문제는 무엇인지 알지 못합니다.
도움 나 PLZ ~