-
Bug
-
Resolution: Fixed
-
P4
-
hs13, 6
-
b13
-
x86
-
windows_2000, windows_2003
---------------------------------------------------
public class uu {
public static void main(String[] args) throws Throwable {
long t0 = System.currentTimeMillis();
java.util.concurrent.TimeUnit.MILLISECONDS.sleep(3);
System.out.println(System.currentTimeMillis()-t0);
}
}
---------------------------------------------------
should print a number no less than 3, but on windows-amd64
and more rarely, windows-i586, it often prints 0.
Probably a hotspot bug (but it could conceivably be core libraries)
This causes j2se regtest test/java/util/concurrent/TimeUnit/Basic.java to fail
Doug Lea asked,
What happens if you instead just call Thread.sleep(3)?
Good question.
-----------------------------------------------------
public class uu {
public static void main(String[] args) throws Throwable {
if (args.length == 1 && args[0].equals("TimeUnit")) {
long t0 = System.currentTimeMillis();
java.util.concurrent.TimeUnit.MILLISECONDS.sleep(3);
System.out.println(System.currentTimeMillis()-t0);
} else if (args.length == 1 && args[0].equals("Thread")) {
long t0 = System.currentTimeMillis();
Thread.sleep(3);
System.out.println(System.currentTimeMillis()-t0);
}
}
}
-----------------------------------------------------
The above program, when invoked with either argument "Thread" or "TimeUnit"
prints "0" on windows-amd64 most of the time.
So this is definitely not a TimeUnit bug.
- blocks
-
JDK-8230423 Move os::sleep to JavaThread::sleep
-
- Resolved
-
-
JDK-8230424 Use platform independent code for Thread.interrupt support
-
- Resolved
-
- relates to
-
JDK-5068368 (thread) Thread.sleep should say "at least as long" and implement this guarantee
-
- Closed
-
-
JDK-6435126 ForceTimeHighResolution switch doesn't operate as intended
-
- Closed
-
-
JDK-8229516 Thread.isInterrupted() always returns false after thread termination
-
- Resolved
-
-
JDK-6824583 regtest TimeUnit/Basic.java fails intermittently on Windows - again
-
- Resolved
-
-
JDK-6498581 ThreadInterruptTest3 produces wrong output on Windows
-
- Closed
-
-
JDK-8252200 Thread::sleep(1) time is longer than 1ms in Java 14 on Windows 10
-
- Closed
-
-
JDK-5005837 rework win32 timebeginperiod usage
-
- Closed
-