my $thread300 = async {
while( sleep 300 ) {
...
}
};
####
my $timeToExit : shared = 0;
sub shutdown{
print logTime." INT|ABRT|QUIT|TERM received....shutting down service.\n";
$timeToExit = 1; ## Tell the threads to quit
sleep 1; ## give them time to react
close(LOOK_FOR_LEASE) if fileno(LOOK_FOR_LEASE);
close(OUTPUT) if fileno(OUTPUT);
close(ERROR) if fileno(ERROR);
threads->exit();
}
...
my $thread300 = async {
my $sleepTime = 300;
while( !$timeToExit ) {
sleep 1 and next while --$sleepTime;
$sleepTime = 300;
...
}
};
####
c:\test> \perl32\bin\perl -Mthreads -e"print $]; async{ sleep 1000 }->detach; sleep 5"
5.008009
c:\test>