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
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
- duplicates
-
JDK-4503551 Too short waits: roll forward 4275818 from 1.2.2.x
-
- Closed
-
- relates to
-
JDK-4373068 Thread.sleep() does not work as expected in Solaris.
-
- Closed
-
-
JDK-4295241 1.3FCS-P,HotSpot,Solaris: Object.wait(timeout) waits for incorrect elapsed time
-
- Closed
-