What is happening to all not finished tasks (threads) after joinUntil throws TimeoutException

Alan Bateman alan.bateman at oracle.com
Tue Apr 8 06:24:58 UTC 2025


On 07/04/2025 22:36, Sergii Chekotylo wrote:
> Thank you for response Alan.
>
> I have another question about closing the scope (exiting try-with-resources):
>  From the code in the fork() method I’ve realized that methods join()/joinUntil() not intended to be called only once inside the single scope instance. And it is aligned with my use case. But what to do with TimeoutException? Of course I can wrap joinUntil in separate try-Catch, but how to interrupt all unfinished tasks without closing the scope?
>
> Or maybe I just wrong about usage of the scope and it is intended to be used only once?
>
The intention is that there is only one "fork phase" so no forking after 
join. The current API/implementation allows several phases, the updated 
API that has been proposed fixes that issue.

For your use-case then might want to use the shutdown method as it will 
shut down the task scope (this interrupts the threads executing all 
unfinished tasks) without closing the scope.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20250408/ad078576/attachment.htm>


More information about the loom-dev mailing list