my $t = threads->create (sub{ ## You run your thread function here &$functions_name(@parameters); ## And when it has completed -- if it ever does -- ## You set up a signal handler ... $SIG{KILL} = sub { print "\ngot to thread killer\n\n"; threads->exit(); }; print "\ngot to end of thread\n\n"; #$shutdown = 1; ## and then exit the thread. });