< prev index next > src/java.base/share/classes/java/lang/ScopedValue.java
Print this page
*
* {@snippet lang=java :
* private static final ScopedValue<String> NAME = ScopedValue.newInstance();
* ScopedValue.where(NAME, "duke").run(() -> {
! * try (var scope = new StructuredTaskScope<String>()) {
*
* // @link substring="fork" target="StructuredTaskScope#fork(java.util.concurrent.Callable)" :
* scope.fork(() -> childTask1());
* scope.fork(() -> childTask2());
* scope.fork(() -> childTask3());
*
* {@snippet lang=java :
* private static final ScopedValue<String> NAME = ScopedValue.newInstance();
* ScopedValue.where(NAME, "duke").run(() -> {
! * // @link substring="open" target="StructuredTaskScope#open()" :
+ * try (var scope = StructuredTaskScope.open()) {
*
* // @link substring="fork" target="StructuredTaskScope#fork(java.util.concurrent.Callable)" :
* scope.fork(() -> childTask1());
* scope.fork(() -> childTask2());
* scope.fork(() -> childTask3());
< prev index next >