<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi Mark,</div><div><br></div><div style="">I noticed an error and a formatting issue in the document: </div><div><br></div><div>1. Missing closing bracket before the `throws`:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><pre style="font-family:"DejaVu Sans Mono","Bitstream Vera Sans Mono","Luxi Mono","Courier New",monospace;font-size:13.3333px;padding-left:2em;margin-top:1ex;margin-bottom:1ex;color:rgb(0,0,0)"><code style="font-family:"DejaVu Sans Mono","Bitstream Vera Sans Mono","Luxi Mono","Courier New",monospace"><T> List<T> runConcurrently(Collection<Callable<T>> tasks throws InterruptedException {
    try (var scope = StructuredTaskScope.open(Joiner.<T>allSuccessfulOrThrow())) {
        tasks.forEach(scope::fork);
        return scope.join().map(Subtask::get).toList();
    }
}</code></pre></blockquote><div><br></div><div>2. There is extra space after the `extends` in `Subtask<? extends  T><span style="font-family:"DejaVu Sans Mono","Bitstream Vera Sans Mono","Luxi Mono","Courier New",monospace;color:rgb(0,0,0);font-size:13.3333px">`:</span></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><pre style="font-family:"DejaVu Sans Mono","Bitstream Vera Sans Mono","Luxi Mono","Courier New",monospace;font-size:13.3333px;padding-left:2em;margin-top:1ex;margin-bottom:1ex;color:rgb(0,0,0)"><code style="font-family:"DejaVu Sans Mono","Bitstream Vera Sans Mono","Luxi Mono","Courier New",monospace">class CollectingJoiner<T> implements Joiner<T, Stream<T>> {

    private final Queue<T> results = new ConcurrentLinkedQueue<>();

    public boolean onComplete(Subtask<? extends  T> subtask) {
        if (subtask.state() == Subtask.State.SUCCESS) {
            results.add(subtask.get());
        }
        return false;
    }

    public Stream<T> result() {
        return results.stream();
    }

}</code></pre></blockquote><div><br></div><div>Glavo </div></div></div></div></div></div></div></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Tue, Apr 15, 2025 at 3:17 AM Mark Reinhold <<a href="mailto:mark.reinhold@oracle.com">mark.reinhold@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><a href="https://openjdk.org/jeps/505" rel="noreferrer" target="_blank">https://openjdk.org/jeps/505</a><br>
<br>
  Summary: Simplify concurrent programming by introducing an API for<br>
  structured concurrency.  Structured concurrency treats groups of<br>
  related tasks running in different threads as single units of work,<br>
  thereby streamlining error handling and cancellation, improving<br>
  reliability, and enhancing observability.  This is a preview API.<br>
<br>
- Mark</blockquote></div>