in reply to a question on threads

use Time::Hires qw(time usleep); while(1) { my $now = time; my $next = int($now+1); usleep $next-$now; foo; bar; # your work here! }

Replies are listed 'Best First'.
Re^2: a question on threads
by Roy Johnson (Monsignor) on May 12, 2005 at 02:08 UTC
    If you did the work first and did the sleep after, you wouldn't have slippage induced by the the time it takes to do the work.

    Caution: Contents may have been coded under pressure.
      that doesn't matter. i'm afraid. the actions have to be taken nearly every 1 second. so, the tiome, when the thread falls asleep, won't be of any effect - as long as it sleeps for a while as close to a second as possible.

      language is a virus from outer space.