my $threadcount = 10; my $jobs = Thread::Queue->new(@xyz); # I use undef as marker when to stop working $jobs->enqueue(undef) for 1..$threadcount; my @workers = map { threads->create( \&work ) } 1..$threadcount; sub work { while (defined (my $item = $jobs->dequeue)) { print "Processing $item\n"; }; };