Details
-
Enhancement
-
Resolution: Fixed
-
P3
-
repo-loom
Description
The spec for `Thread.Builder.inheritInheritableThreadLocals` is:
“Sets whether the thread inherits the initial values of inheritable-thread-local variables. The default is to inherit.
The initial values of InheritableThreadLocals are never inherited when allowSetThreadLocals(boolean) is used to disallow the thread to have its own copy of thread-local variables.”
https://github.com/openjdk/loom/blob/4406b8ee7233d4765f5e1b27d09e9fb0b1e09dbe/src/java.base/share/classes/java/lang/Thread.java#L869
In fact what's inherited (or not) is not “the initial TL's value” but “the current value” (the one set lately) that might be different from the original initial value for a TL.
“Sets whether the thread inherits the initial values of inheritable-thread-local variables. The default is to inherit.
The initial values of InheritableThreadLocals are never inherited when allowSetThreadLocals(boolean) is used to disallow the thread to have its own copy of thread-local variables.”
https://github.com/openjdk/loom/blob/4406b8ee7233d4765f5e1b27d09e9fb0b1e09dbe/src/java.base/share/classes/java/lang/Thread.java#L869
In fact what's inherited (or not) is not “the initial TL's value” but “the current value” (the one set lately) that might be different from the original initial value for a TL.