Thread.sleep(timeout) is influenced by changes to System time on *_Linux_*.
Tested both on:
Red Hat Linux release 9 (Shrike)
Kernel 2.4.20-8 on an i686
and
Red Hat Enterprise Linux ES release 3 (Taroon Update 4)
The test is simple,
call Thread.sleep(15000) and change the time two hours back
i.e. start at 13:00 call thread.sleep and at 13:05 change the time to 11:05
you will notice that the sleep does not return at 11:15, not even when the time
is then fixed back to 13:15
The test case is simple,
System.out.println("Press key before sleeping for 15 seconds...");
System.in.read();
Thread.sleep(15000);
System.out.println("Woke-up.");
---
e.g.
run the test, Press <Enter> at 11:34:00 (00 seconds)
At 11:34:05 change the clock to 09:34:05 (two hours back)
Expected result: at 09:34:15 the thread will wake up.
If the same test is conducted on Windows machine then it works.
If the clock is set to a _future _time, the test works also for linux.
I have tested this with the following JDKs:
1. Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
[ FAILED ]
2. Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
[ FAILED ]
3. Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-b05)
Java HotSpot(TM) Client VM (build 1.4.2_07-b05, mixed mode)
[ PASSED ]
---
Please note that this same test _*PASSED*_ on build 1.4.2_07-b05.
Please find attached are the following:
Tester.java - test case
specification.txt - machine specification
threadDump.txt - thread dump while thread.sleep didn't wake up