sub worker_thread { while ( my $item = $processing_q -> dequeue() ) { # do stuff to $item } } for ( my $count = 0; $count < $nthreads; $count++ ) { my $thr = threads -> create ( \&worker_thread ); } $processing_q -> enqueue ( @server_list ); $processing_q -> end; foreach my $thread ( threads -> list() ) { $thread -> join(); } #### my $thread_exclusion = Thread::Semaphore -> new ( -1 * $nthreads + 1 ); #### $thread_exclusion -> up(); #### sub close_queues { $exclusion_lock -> down(); $process_q -> end(); } #### $SIG{'ALRM'} = \&close_queues(); alarm ( 60 );