Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
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.
|