JDK-8056152 : (thread) API to create Threads that do not inherit inheritable thread-local initial values
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-08-27
  • Updated: 2020-07-09
  • Resolved: 2015-12-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b99Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
Examine the possibility of constructing Threads that do not inherit inheritable thread-local initial values.
Such an API could be used to replace most usages of sun.misc.ManagedLocalsThread in the JDK.
Comments
A simple sketch might look like: /** * Allocates a new {@code Thread} object so that it has {@code target} * as its run object, has the specified {@code name} as its name, * belongs to the thread group referred to by {@code group}, has * the specified <i>stack size</i>, and inherits initial values for * {@linkplain InheritableThreadLocal inheritable thread-local} variables * if {@code inheritThreadLocals} is {@code true}. * * <p> This constructor is identical to {@link * #Thread(ThreadGroup,Runnable,String,long)} with the added ability to * suppress, or not, the inheriting of initial values for inheritable * thread-local variables from the constructing thread. This allows for * finer grain control over inheritable thread-locals. Care must be taken * when passing a value of {@code false} for {@code inheritThreadLocals}, * as it may lead to unexpected behavior if the new thread executes code * that expects a specific thread-local value to be inherited. * * <p> Specifying a value of {@code true} for the {@code inheritThreadLocals} * parameter will cause this constructor to behave exactly like the * {@code Thread(ThreadGroup, Runnable, String, long)} constructor. * * ... * @param inheritThreadLocals * if {@code true}, inherit initial values for inheritable * thread-locals from the constructing thread, otherwise no initial * values are inherited */ public Thread(ThreadGroup group, Runnable target, String name, long stackSize, boolean inheritThreadLocals) ... with an appropriate comment in InheritableThreadLocal noting this.
08-12-2015