#!/usr/bin/env perl use strict; use warnings; use threads; sub worker { print "Worker thread started.\n"; while(1){} } my $thread = threads->create(\&worker); print "Setting alarm.\n"; $SIG{ALRM} = sub { die "Alarm!\n" }; alarm 2; print "Check join\n"; while (threads::running) { $_->join for threads->list(threads::joinable); }