Here's a very basic skeleton that will serve as a basis for you to tweak to do the job. It uses a prioritising subclass of Thread::Queue to 'schedule' the repeat jobs:

#! perl -slw use strict; use threads; use Thread::Queue; use LWP::Simple; { package T::Q::O; use Data::Dump qw[ pp ]; require Thread::Queue; use threads; use threads::shared; our @ISA = 'Thread::Queue'; sub enqueue { local $^W; my $Q = shift; lock @$Q; for( @_ ) { push @$Q, $_; my $n = $#$Q; @{ $Q }[ $n, $n-1 ] = @{ $Q }[ $n-1, $n ], --$n while $n-1 and $Q->[ $n ] < $Q->[ $n - 1 ]; } cond_signal( @$Q ); } sub dump { my $Q = shift; lock @$Q; pp $Q; cond_signal( @$Q ); } } sub dbiFetch { my @args = @_; return getstore $args[ 0 ], 'nul'; } sub sshFetch { my @args = @_; return getstore $args[ 0 ], 'nul'; } sub tcpFetch { my @args = @_; return getstore $args[ 0 ], 'nul'; } sub worker { no strict 'refs'; my $Q = shift; while( my $work = $Q->dequeue ) { my( $time, $interval, $sub, @args ) = split $;, $work; sleep 1 while time() < $time; # printf "now: %.f time:$time int:$interval sub:$sub [@args]", +time(); my $result = $sub->( @args ); # print $result; $Q->enqueue( join $;, $time + $interval, $interval, $sub, @arg +s ); } } our $W //= 10; my $Q = new T::Q::O; my @workers = map async( \&worker, $Q ), 1 .. $W; while( <> ) { chomp; $Q->enqueue( join $;, time(), (map $_*60, 1,2,3 )[ rand 3 ], ( qw[dbiFetch sshFetch tcpFetch ] )[ rand 3 ], $_ ); } 1 while sleep 1;

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

In reply to Re^13: Thread Design help by BrowserUk
in thread Thread Design help by perlCrazy

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.