4

I wrote an actor, using a scheduler each 5 milliseconds to assign a time stamp to a field.

And in test, I found that the result of (System.currentTimeMillis() - timeField) is at least 35

And if I use a scheduleAtFixedRate() method from the Executors.scheduledThreadPool, the result is right.

So is the scheduler delay has a min value ?

Answer: the default tick duration is 100 milliseconds.

user1453345
  • 338
  • 2
  • 10

2 Answers2

3

ScheduledThreadPoolExecutor uses System.nanoTime(): http://fuseyism.com/classpath/doc/java/util/concurrent/ScheduledThreadPoolExecutor-source.html

See comparison here: System.currentTimeMillis vs System.nanoTime

Community
  • 1
  • 1
Andriy Plokhotnyuk
  • 7,883
  • 2
  • 44
  • 68
  • Thanks, but it is not for my question:) – user1453345 Jul 11 '12 at 15:49
  • 1
    It looks that HashedWheelTimer uses Thread.sleep(long millis, int nanos) which has about ~1 milliseconds resolution in JDK on most platforms and can rise up to 15 milliseconds when running in server mode on Windows... – Andriy Plokhotnyuk Jul 11 '12 at 17:21
1

Akka has a fairly extensive documentation.

Here's an excerpt:

"The default implementation of Scheduler used by Akka is based on the Netty HashedWheelTimer. It does not execute tasks at the exact time, but on every tick, it will run everything that is overdue. The accuracy of the default Scheduler can be modified by the “ticks-per-wheel” and “tick-duration” configuration properties. For more information, see: HashedWheelTimers."

Viktor Klang
  • 26,479
  • 7
  • 51
  • 68