Original problem description (addressed now: see evaluation):
Users are sometimes reading the javadoc for the two Thread sleep methods
and interpreting it to mean that a program will sleep for *exactly* the
time they are specifying. In reality, all current implementations have an
additional delay before the program resumes execution. Several bugs have
been filed (and closed) about this.
Current problem description:
The Thread.sleep spec should say that sleep "Causes the currently executing thread to sleep (temporarily cease execution) for at least the specified number of milliseconds...." (important text is "at least") And the Java SE implementation has rounding policies (e.g. for nanoseconds in sleep's two parameter method) that would not correctly implement this specification change: a code change to implement the "at least" spec properly is also required (see suggested fix).
Users are sometimes reading the javadoc for the two Thread sleep methods
and interpreting it to mean that a program will sleep for *exactly* the
time they are specifying. In reality, all current implementations have an
additional delay before the program resumes execution. Several bugs have
been filed (and closed) about this.
Current problem description:
The Thread.sleep spec should say that sleep "Causes the currently executing thread to sleep (temporarily cease execution) for at least the specified number of milliseconds...." (important text is "at least") And the Java SE implementation has rounding policies (e.g. for nanoseconds in sleep's two parameter method) that would not correctly implement this specification change: a code change to implement the "at least" spec properly is also required (see suggested fix).
- relates to
-
JDK-6312446 (spec thread) Bring Thread.sleep spec in line with JLS 17.9
- Resolved
-
JDK-6313903 Thread.sleep(3) might wake up immediately on windows
- Resolved
-
JDK-4373068 Thread.sleep() does not work as expected in Solaris.
- Closed
-
JDK-6568526 (thread) Thread.sleep(millis, nanos) should not return early
- Closed
-
JDK-4365109 (thread) Thread.sleep() sleeps more than required on dualprocessor
- Closed
-
JDK-6298653 Use finest granularity clock (System.nanoTime) for sleep, wait, util.Timer ...
- Closed
(1 relates to)