<div dir="auto"><div dir="auto">> But even if I know that in such a case I should make some kind of "atomic assertion or +1" after each .fork() calls, I don't have a clue upon which event I have room to make the corresponding "atomic assertion & -1" with the new API.</div><div dir="auto"><br></div><div dir="auto">All of the user definable behaviour has moved into the Joiner class, when opening a sts you can pass a joiner to it.</div><div dir="auto"><br></div><div dir="auto">Joiner has a "onFork" method that invokes whenever you call "scope.fork", a "onComplete" method that invokes whenever a task completes (successfully or unsuccessfully) and "complete" method that invokes from the "scope.join" method (it is invoked *after* all the tasks are supposedly ended)</div><div dir="auto"><br></div><div dir="auto">What you want is e.g. a semaphore acquisition in your "onFork" override and a release in your "onComplete".</div><div dir="auto"><br></div><div data-smartmail="gmail_signature" dir="auto"><div dir="ltr"><br></div></div><br><div class="gmail_quote gmail_quote_container" dir="auto"><div dir="ltr" class="gmail_attr">On Tue, 23 Dec 2025, 21:15 Benoit LEFEVRE -CAMPUS-, <<a href="mailto:benoit.lefevre@decathlon.com">benoit.lefevre@decathlon.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello<div><br></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>Thanks Attila & Alan for your feedback, and sorry for this late reply of mine.<br><br>Weeks before Christmas are pretty busy at work :p</div><div><br></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px">@Attila : I quickly thought about something like what you advise.<br><br>But even if I know that in such a case I should make some kind of "atomic assertion or +1" after each .fork() calls, I don't have a clue upon which event I have room to make the corresponding "atomic assertion & -1" with the new API.<br><br>If it's still possible with it, I have most probably missed something. <br><br>I remember that in its previous version, there were some kind of callbacks methods whose implementations could be overloaded.<br><br>But now the API is much more composition oriented, where do you advise to code this ?<br><br>@Alan : Do you have the references of those discussions by any changes ?<br><br>As is, it's not straightforward for me to understand how the ThreadFactory can keep track or be warned whenever a thread it created complete.<br><br></blockquote></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 15 déc. 2025 à 21:50, Attila Kelemen <<a href="mailto:attila.kelemen85@gmail.com" target="_blank" rel="noreferrer">attila.kelemen85@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Yeah, I was on those threads. Though I much dislike the idea doing this with a `ThreadFactory`, because then you would have to do an `acquire` before returning a thread, and generally no API makes the promise that a thread created by the factory will be started (though would be unusual, but still I prefer to code for the contract). If you want to abstract it, then it is way better to hide this behind an `Executor` (or `ExecutorService`) where you can implement this properly (if we restrain ourselves to JDK interfaces).</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Alan Bateman <<a href="mailto:alan.bateman@oracle.com" target="_blank" rel="noreferrer">alan.bateman@oracle.com</a>> ezt írta (időpont: 2025. dec. 15., H, 21:32):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On 15/12/2025 19:29, Attila Kelemen wrote:<br>
> If I'm understanding your problem correctly, then you can just use <br>
> semaphores to limit the number of concurrent actions.<br>
><br>
There are a few other threads to the same topic in the archives. Using a <br>
ThreadFactory that limits concurrency is one of the options that others <br>
were trying out.<br>
<br>
-Alan<br>
</blockquote></div>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Benoit Lefèvre</div></div>
</blockquote></div></div>