#!/usr/bin/perl use strict; use warnings; use threads; use threads::shared; # 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 { my $i = 0; while ($keepRunningProgressBar == 1) { if ($i++ % 10 == 0) { print ".\n"; } sleep(1); } } ); # Now do stuff in the work thread my $threadForSpidering = threads->new( sub { my $i = 0; while ($i++<5) { print "Working\n"; sleep 1; }}); #The work thread finished $threadForSpidering->join; #And tells the progress bar to stop running $keepRunningProgressBar = 0; $progressBar->join; print "\nGOT HERE\n"; #### #!/usr/bin/perl use strict; use warnings; use threads; use threads::shared; # 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 ".\n"; sleep(10); } ); # Now do stuff in the work thread # Now do stuff in the work thread my $threadForSpidering = threads->new( sub { my $i = 0; while ($i++<5) { print "Working\n"; sleep 1; }}); #The work thread finished $threadForSpidering->join; #And tells the progress bar to stop running $keepRunningProgressBar = 0; $progressBar->kill('KILL')->detach(); print "\nGOT HERE\n";