Get the latest tech news
JEP 506: Scoped Values final for Java 25
mmary Introduce scoped values, which enable a method to share immutable data both with its callees within a thread, and with child threads. Scoped values are easier to reason about than thread-local variables.
The preferred mechanism for user code to create virtual threads is the Structured Concurrency API ( JEP 505), specifically the class StructuredTaskScope. However, carrying the additional baggage of thread-local variables results in an implementation that is unduly burdensome, or an API that returns UnsupportedOperationException for much of its core functionality, or both. We ultimately rejected that idea because it is impossible to guarantee correct operation when relying on user code to invoke the close method at the right time.
Or read this on Hacker News