Not sure this applies to your specific situation, David, but for the other readers of this conversation I also want to raise the point that implementing a Joiner must be done in a thread-safe manner.
Cheers, √ Viktor Klang Software Architect, Java Platform Group Oracle ________________________________ From: loom-dev <loom-dev-r...@openjdk.org> on behalf of Alan Bateman <alan.bate...@oracle.com> Sent: Sunday, 24 August 2025 08:19 To: David Alayachew <davidalayac...@gmail.com> Cc: loom-dev <loom-dev@openjdk.org> Subject: Re: When should I use onFork? On 23/08/2025 20:27, David Alayachew wrote: > Woah, very good to know. And thus, even when the scope is closed, > onFork will still be called is what you are saying? > > Thanks for this. Very useful. > No, fork is specified to throw IllegalStateException if closed. My comment is pointing out that if you cancel the scope then the result from any subtasks that are still executing does not contribute to the outcome. Once you cancel then onComplete for these "still running (and interrupted)" subtasks won't be called. To put it another way, if the outcome from join is something derived from all subtasks that were forked then you'll need to implement onFork. It may be more common that the outcome is derived from the result/exception from a subset of the subtasks, in which case it will be the onComplete method that you implement. -Alan