Why we need Scoped Values?
You may want to transfer data between distinct components of your software, such as a web framework and a database access layer, on occasion. For example, You may wish to share a user’s identity or permissions between many request threads. Thread-local variables, which have different values for each thread, are one technique.
Scoped Values in Java
In Java, Scoped variables enable the exchange of immutable data across and between threads. This new API is implemented as an incubator preview feature in Java 20 as part of JEP 439. They are preferred over thread-local variables, especially when a large number of virtual threads are used. This is an API that is still in development.
Contact Us