< prev index next >

src/java.base/share/classes/java/lang/ScopedValue.java

Print this page
*** 156,11 ***
   *
   * {@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());
--- 156,12 ---
   *
   * {@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 >