my $q = Thread::Queue->new; ## create a new **EMPTY** queue my $done : shared; $done = 0; my $wget_thread = threads->create( \&wget_sub ); my $cpu_monitor_thread = threads->create( \&monitor_cpu ); ## Start your threads with the queue empty/ my $mem_monitor_thread = threads->create( \&monitor_mem ) #### sub monitor_cpu { my $cap; while ( my $val = $q->peek(0) ) { #this does not get evaluated to true, ever $cap .= `bash cpu.sh; sleep 2`; } return $cap; } #### my $done :shared = 0; ... sub monitor_cpu { my $cap; until( $done ) { $cap .= `bash cpu.sh; sleep 2`; } return $cap; } ... my $mon = threads->new( \&monitor_cpu ); ... do other stuff ## To stop the queue(s) $done = 1; $mon->join;