System.nanoTime() drift

There seems to be a problem with System.nanoTime() on Sun-Fire-T200 with Solaris 10.

Small test showed that nanotime runs faster than millitime and the difference is 1 second per hour.

As java.util.concurrent.ScheduledThreadPoolExecutor uses nanotime this time drift issue makes the usage of scheduler quite useless as the tasks scheduled with fixed rate are executed too early

For example if you schedule a task to run at every midnight then when your system has been up for a month the task will not start at midnight but about 12 minutes before midnight.

Has anyone else noticed this? What could cause such thing?

I've checked this also on Sun-Fire-V210 and there was everything ok.

[724 byte] By [randodnara] at [2007-11-27 5:35:37]
# 1

If the problem is reproducable (aka the small tests you mention) then report a bug.

http://bugs.sun.com/services/bugreport/index.jsp

To answer your questions:

>Has anyone else noticed this?

No idea. Not me anyway.

>What could cause such thing?

As a wild guess one uses the system time and one uses the hardware time and they are out of synch. It's a possibility. And I mention it because if that is the case you could make sure both are synched using the correct time using a NTP service.

cotton.ma at 2007-7-12 15:04:53 > top of Java-index,Java Essentials,Java Programming...