我想理解,因为如果我运行这段代码
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use threads;
use threads::shared;
sub mythread {
my $end = 0; # Thread termination variable
while(!$end) {
eval {
local $SIG{'ALRM'} = sub {
print "SIGALARM received\n";
$end = 1;
die "Alarm!\n";
};
sleep(5); # Wait
};
die $@ unless $@ eq "Alarm!\n";
}
}
my $end = 0; # Main termination variable
$SIG{'INT'} = sub {
$end = 1; # Set Main termination variable
};
my $thr = threads->create( \&mythread …Run Code Online (Sandbox Code Playgroud)