[concurrency-interest] ScheduledThreadPoolExecutor schdeuling problem ?

Hanson Char hanson.char at gmail.com
Mon Dec 31 12:01:12 EST 2007


This is really strange.  The problem occurred at least on Linux
platforms.  The one I am using is

  Linux version 2.4.21-37a8 (gcc version 3.2.3 20030502 (Red Hat Linux
3.2.3-47))

Hey John, you mentioned you had a unit test that exhibits the problem
intermittently.  Would you mind sharing it so we potentially can have
it fixed by the experts ?

Regards,
Hanson Char

On Dec 31, 2007 5:59 AM, Doug Lea <dl at cs.oswego.edu> wrote:
> Hanson Char wrote:
> > (I refer to JDK 6+). It seems a scheduled event via
> >
> >   ScheduledThreadPoolExecutor.schedule(Runnable command, long delay,
> > TimeUnit unit)
> >
> > may occur before the target time.  For example, if an event is
> > scheduled to occur 1000ms from now.  The event could actually get
> > triggered after 990ms ie 10 ms less than the specified delay.
> >
> > Is this a known issue ?  Shouldn't the event be delayed for at least
> > the specified delay time ?
> >
>
> I hope David Holmes also answers this, since he knows most about
> platform-level timing issues. But I don't know of any problems
> that affect ScheduledThreadPoolExecutor in this way. Internally,
> methods recheck times to ensure that they do not fire too early.
> (See DelayQueue.take and related methods). On some platforms
> (including Windows), there may be some *apparent* differences
> in times if you are monitoring times with System.currentTimeMillis()
> versus System.nanoTime() -- these use different clocks that may become
> out of sync. ScheduledThreadPoolExecutor uses nanoTime, which should in
> general be more accurate.
>
> -Doug
>


More information about the Concurrency-interest mailing list