A
Andrew Connick
I'm having some trouble using Thread.sleep(long millis, int nanos); it
seems to simply use the nanosecond argument to decide whether the
milliseconds argument should be rounded up or not.
When calling Thread.sleep(2, 0) in the body of a long-running for loop
the total time taken is approx. 7secs. This is the same time taken
using Thread.sleep(2, 499999). If I change the arguments and call
Thread.sleep(2,500000) the total time is over 10secs - exactly the
same as using Thread.sleep(3,0).
The API docs states "Causes the currently executing thread to sleep
(cease execution) for the specified number of milliseconds plus the
specified number of nanoseconds", but this is clearly not happening.
Could it be a problem with my JVM? I'm using Sun's Java 1.4.2_03.
Any help would be greatly appreciated!
--Andrew
seems to simply use the nanosecond argument to decide whether the
milliseconds argument should be rounded up or not.
When calling Thread.sleep(2, 0) in the body of a long-running for loop
the total time taken is approx. 7secs. This is the same time taken
using Thread.sleep(2, 499999). If I change the arguments and call
Thread.sleep(2,500000) the total time is over 10secs - exactly the
same as using Thread.sleep(3,0).
The API docs states "Causes the currently executing thread to sleep
(cease execution) for the specified number of milliseconds plus the
specified number of nanoseconds", but this is clearly not happening.
Could it be a problem with my JVM? I'm using Sun's Java 1.4.2_03.
Any help would be greatly appreciated!
--Andrew