The sleep function does not accuratly block for the specified
milliseconds.
please try the program listed below :
*********** timeTest.java ****************
class timeTest
{
public static void main(String[] args)
{
long start = System.currentTimeMillis();
for(int i = 0;i < 1000;i++) {
try {
Thread.sleep(1);
} catch( InterruptedException ex) {}
}
long stop = System.currentTimeMillis();
System.out.println(" Time taken : " + (stop - start));
}
}
**********************************************
on running this program in Solaris 8 & Solaris 7 with jdk1.2.2
the program prints a result of 19992 milliseconds.
on windows NT, I get the correct expected result of 1002 milliseconds.
I get varying results with other JDK's ( with 1.3 it took 10003 ms)
in Solaris.
clearly the sleep function is broken for the solaris environment
as it does not block accuratly for the specified time.
balaji.raghunathan@eng 2000-09-21
Thread.sleep() for nano seconds time interval does not work too.
Thread.sleep() simply does not timeout properly for any given
time interval. This could be a very serious problem in all Java
based server software for the Solaris platform. note: it works ok in
Windows NT and that makes this bug even more important to fix.
- duplicates
-
JDK-5041555 Thread.sleep sleeps extra 10ms. (Thread.sleep(1000) -> 1010ms).
-
- Closed
-
- relates to
-
JDK-6312446 (spec thread) Bring Thread.sleep spec in line with JLS 17.9
-
- Resolved
-
-
JDK-5068368 (thread) Thread.sleep should say "at least as long" and implement this guarantee
-
- Closed
-
-
JDK-4313182 Thread.sleep(millis, nanos) sleeps for incorrect time.
-
- Closed
-
-
JDK-6298653 Use finest granularity clock (System.nanoTime) for sleep, wait, util.Timer ...
-
- Closed
-
-
JDK-4240408 java.lang.Thread.sleep(millis, nanos) sleeps less than specified.
-
- Closed
-
(1 relates to)