#!/usr/bin/perl use Cwd qw/realpath/; use File::Basename qw/dirname/; use lib 'lib'; use threads; use threads::shared; use initial; my @threads = (); my $run :shared = 1; sub proc1 { while($run){ sleep(1); print "I am child thread 1 \n" } } sub proc2 { while($run){ sleep(1); print "I am child thread 2 \n"; } } threads->create(\&proc1); threads->create(\&proc2); my $init = load initial($name); $SIG{'TERM'} = sub { $run = 0; }; while($run){ sleep(1); print "I am main thread\n"; } $_->join() for threads->list();