The Scoped Values
API allows us to store and share immutable data for a bounded lifetime. It has been included in the JDK since Java 20 as an incubator API. This repository shows how you can use it with Virtual Threads
and Structured Concurrency
.
JDK 20 or later
mvn clean install
jar cmf ./META-INF/MANIFEST.FM scoped-values.jar -C ./target/classes/ .
or
sh ./compile.sh
java --enable-preview --add-modules jdk.incubator.concurrent -jar scoped-values.jar
or
sh ./run.sh