do { ... } while ($worker->pending()); #### sub doOperation () { my $ithread = threads->tid(); while( my $folder = $worker->dequeue() ) { print "Read $folder from queue with thread $ithread\n" if $debug; ## Do something useful here... } }