System.currentTimeMillis() is bugged on Windows systems. At any point it can be inaccurate by 0-20 milliseconds- more if under heavy load or while running on an Athlon 64(this is a seperate bug though) The bug has been documented but not fixed completely. Part of Sun's solution was to include a higher resolution timer in the release of Java 1.5: System.nanoTime()
This is actually a repackage of a debug timer used internally by a few Sun packages, but it works great nonetheless.
If you're still getting erratic results try executing the code using the server VM.
Last edited by Robaggio; 09-12-2005 at 07:47 PM..
|