Developers using the incubator API will need some code and command line changes to use the preview API.
The java.lang package is implicitly imported on demand so adding anything to java.lang may be a source incompatible change. We aren't expecting any issues with the name "ScopedValue".
This is the CSR for JEP 446: Scoped Values (Preview).
Introduce scoped values, which enable the sharing of immutable data within and across threads. They are preferred to thread-local variables, especially when using large numbers of virtual threads.
The motivation in the JEP explains the disadvantages of alternative approaches to Scoped Values at some length.
Add a simple API that allows the one-way transmission of data from caller to callees within the same dynamic scope. This scope is not just that of a single thread: it extends to allow scoped values in a parent thread to be automatically inherited by child threads created with
The preview APIs proposed are:
In conjunction with JEP 453, remove module jdk.incubator.concurrent.
The specdiffs are attached.