# set a shared value of TRUE for running the progress bar my $keepRunningProgressBar : shared = 1; # Set the progress bar running indefinitely my $progressBar = threads->create(sub { while ($keepRunningProgressBar == 1) {print ""; sleep(10);} }); $progressBar->detach; # Now do stuff in the work thread my $threadForSpidering = threads->new(\&workthread, $category, $contents, $userRunningBot,$userIPAddress); #The work thread finished $threadForSpidering->join; #And tells the progress bar to stop running $keepRunningProgressBar = 0;