Problem report on the usage of Structured Concurrency (5th preview)

Alan Bateman alan.bateman at oracle.com
Sat Oct 4 16:57:42 UTC 2025


On 02/10/2025 18:29, Pedro Lamarão wrote:
> :
>
> I fail to understand this; I have not tested STS extensively.
> Is it not the case that an inner scope will be cancelled when its 
> parent scope is cancelled?
> The forked subtask would be joining the inner scope; will this inner 
> join not be cancelled when the outer join is cancelled?
> In what sense does an inner scope not participate in the same error 
> handling as the outer scope?
>
When the outer/parent scope is cancelled then all threads executing 
unfinished subtasks will be interrupted. If a subtask has created it own 
scope and invokes join to block waiting for its sub-subtasks, then it 
will wakeup with InterruptedException, and the exception handling will 
cause its scope to be closed, thus interrupting any remaining 
sub-subtasks. So yes, cancelling the parent scope may result in a "tree 
of scopes" being cancelled.

-Alan


More information about the loom-dev mailing list