Partial Results From a Timeout in Structured Concurrency

Alan Bateman alan.bateman at oracle.com
Mon Aug 25 08:47:57 UTC 2025


On 24/08/2025 14:11, Atakan Serin wrote:
> Hi,
>
> One experience using Structured Concurrency:
>
> When there is a timeout, even the succeded subtasks throws illegal 
> state exception, I guess due to the fact that owner is not joined.

The join method can't throw TimeoutException and return a result at the 
same time. Also the SO post is using ShutdownOnFailure but doesn't want 
to shutdown when a subtask fails.

For the example then using STS directly and having a subtask shutdown 
the scope should work, e.g.

scope.fork(() -> {
     Thread.sleep(2000);
     scope.shutdown();
     return null;
});

So no joinUntil or TimeoutException to deal with.

The topic of "give me what you got" before some deadline or timeout 
would be a bit easier in the upgraded API with a Joiner factory method. 
We need to see if this case is common enough to justify that.

-Alan




More information about the loom-dev mailing list