On Wed, May 19, 2021 at 4:01 AM Andrew Haley <aph@redhat.com> wrote:
On 5/15/21 6:50 PM, Peter Levart wrote:
What if I wanted to create and start a thread that would be "pristine" - not have any ScopeLocal value bound? Is this intentionally not allowed in order to make sure that inheritable ScopeLocal(s) can't be cleared by code that has no access to ScopeLocal instance(s)?
That one is about to be changed by a revision to the JEP. There clearly is a need to control whether a newly-created thread inherits scope locals or not. For instance, an Executor might lazily create worker threads, and we don't want them to inherit scope locals from the thread that was running.
Turning this around, I would argue that there are few (or perhaps *no*) cases where it would ever be desirable to inherit scope locals across thread creation; in cases where this is explicitly desired, one can always resume the snapshot from within the thread's Runnable. Was there a particular use case this was meant to address? -- - DML • he/him