use threads ('exit' => 'threads_only'); use Thread::Queue; #create child threads my $childs = 2; my $Q = new Thread::Queue; my @kids = map threads->create(\&processData, $Q), 1 .. $childs # this is how queue work for the processData() once I get some work to do $Q->enqueue($work); sleep 1 while $Q_->pending > $childs; ### How I can check for any errors in a thread here? #Join all the child threads once every work is done $_->join for @kids;