#!/usr/bin/env perl use strict; use warnings; use threads; use constant TIMEOUT => 2; sub worker { print "Worker thread started.\n"; while(1){} } my $thread = threads->create(\&worker); print "Check join\n"; while (1) { $_->join for threads->list(threads::joinable); last unless threads->list(threads::running); die "Alarm!\n" if time - $^T > TIMEOUT; select(undef,undef,undef,0.5); }