-
CSR
-
Resolution: Approved
-
P4
-
behavioral
-
minimal
-
-
Java API
-
JDK
Summary
Update the java.lang.Thread
specification in regards to interruption happening while a thread is not alive, to account for a new implementation that tracks the interrupted state at all times in the thread lifecycle.
Problem
The specification for java.lang.Thread::interrupt
allows for thread interruption to be a no-op if the thread is not alive:
Interrupting a thread that is not alive need not have any effect.
and the Thread::interrupted
and Thread::isInterrupted
method reflect the behaviour of the Hotspot VM by stating:
A thread interruption ignored because a thread was not alive at the time of the interrupt will be reflected by this method returning false.
With the new implementation of the interrupted state an accurate record of the interrupt state of a thread is available at all times in the thread's lifecycle and so these parts of the specification are no longer correct.
Solution
We can remove the statements about returning false; and we can add an implementation note that interruption while a thread is not alive is not ignored.
Specification
For Thread::interrupt
add:
* @implNote In this implementation, interruption of a thread that is not
* alive still records the interrupt request was made and will report it
* via {@link #interrupted} and {@link #isInterrupted()}.
For Thread::interrupted
and Thread::isInterrupted
delete:
* <p>A thread interruption ignored because a thread was not alive
* at the time of the interrupt will be reflected by this method
* returning false.
- csr of
-
JDK-8229516 Thread.isInterrupted() always returns false after thread termination
-
- Resolved
-