use Thread; $huh = Thread->new(\&thread1); for(1..200){ print "This is the main program"; } print "Waiting for thread now"; $stuff = $huh->join(); sub thread1 { for(1..200){ print "Thread1 is running!"; } return 1; }