Duplicate :
|
|
Relates :
|
|
Relates :
|
With kestrel-rc1 the method sleep(millis, nanos) if the java.lang.Thread seems to sleeps a shorter periof of time then specified by parameters. For ex: thread with sleep(1000,1000) actually sleeps an about 970 millisec only with execution on 2 ways Ultra-2. With execution on the same machine but under JDK1.2.2 Solaris refs. the time is equal to 1010 millisec. The following simple test is passed on JDK1.2.2 and is failed with Kestrel. class test extends Thread { boolean done=true; long sleepTime=0; public void run() { long lTime=System.currentTimeMillis(); try{sleep(1000,1000);} catch(Exception E){} sleepTime=System.currentTimeMillis()-lTime; done=true; } static void SleepTest() { test Th1=new test(); Th1.start(); try { Th1.join(); } catch (InterruptedException itr){ } System.out.println("Actual sleep time is " + Th1.sleepTime); if (Th1.sleepTime < 1000) { System.out.println("Test failed."); System.exit(1); } } public static void main(String arg[]) { test.SleepTest(); } } konstantin.boudnik@eng 2000-02-16
|