JDK-8232655 : Deprecate Thread.suspend/resume for removal
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 14
  • Submitted: 2019-10-19
  • Updated: 2019-12-23
  • Resolved: 2019-10-23
Related Reports
CSR :  
Description
Summary
-------

Deprecate, for removal, the methods in `java.lang.Thread` and `java.lang.ThreadGroup` that relate to thread suspension, specifically:

- `Thread.suspend()`
- `Thread.resume()`
- `ThreadGroup.suspend()`
- `ThreadGroup.resume()`
- `ThreadGroup.allowThreadSuspension(boolean)`

These methods have been deprecated since Java SE 1.2 (1998).

Problem
-------

Suspension is inherently deadlock-prone, these APIs have linked to the "Java Thread Primitive Deprecation" page since they were deprecated.

A second issue is that Project Loom is exploring adding support for "lightweight threads" where the notion of suspension will be very different to that defined by the legacy thread suspension mechanism.

Solution
--------

Add "forRemoval=true" to the `Deprecated` annotation on these methods.

No deprecation or changes are proposed to the equivalent APIs in JVM TI or JDI as these are important for debugger operations.

Specification
-------------

The addition of "forRemoval=true" will result in the API docs including a removal warning in the "Deprecated" message.


Comments
Moving to Approved.
23-10-2019

> the notion of suspension will be very different to that defined by the legacy thread suspension mechanism. That would seem to remain a problem as the JVM TI / JPDA notions of thread suspension are aligned with "the legacy thread suspension". Perhaps Loom needs to be careful not to use "suspension" in its terminology (I'm unclear in what context it does, or will, refer to "suspension".) Anyway that is an aside to the current CSR request which I fully endorse.
22-10-2019