Blocks :
|
|
Blocks :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
This program: --------------------------------------------------- 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.
|