So I came up with a proof of concept based on the suggestions here. Please let me know if i am doing anything wrong. Thanks to all who posted:

#!/usr/bin/perl use threads; use Thread::Queue; use threads::shared; our $queue = Thread::Queue->new; my $test = "0"; my $stop_var : shared = 0; for (1..30){ $thr = threads->new(\&thread_sub1); } for (1..30){ $thr1 = threads->new(\&thread_sub); } foreach $thr ( threads->list ) { $thr->join; } foreach $thr1 ( threads->list ) { $thr1->join; } sub thread_sub { my $tid = threads->self->tid(); my $sec=1; until ($sec == 0) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) += localtime(time); # print "$sec\n"; } lock($stop_var); if ($stop_var ==0) { $stop_var = 1; for (1..30){ $queue->enqueue($tid); } } } sub thread_sub1 { my $tid = threads->self->tid(); print "Order thread number $tid spawned\n"; $action1 = $queue->dequeue; print "I have gotten through the queue my lord: $action1\n"; }

In reply to Re: multi-threaded questions by Anonymous Monk
in thread multi-threaded questions by btoovey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.