<div dir="ltr"><div>You can't really acquire everything at once, because you might get so many tasks that you could never fulfil such a request. That said, `invokeAll` can simply be done by submitting all tasks one after another. Implementing `invokeAny` well might be trickier, but I have never seen anyone ever using it, so I wouldn't worry too much about it. But you can check `AbstractExecutorService` for both. In fact, you can actually use it as a base class to provide implementation for the invoke many methods.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Colin Redmond <<a href="mailto:Colin.Redmond@outlook.com">Colin.Redmond@outlook.com</a>> ezt írta (időpont: 2024. máj. 13., H, 23:05):<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 class="msg1736266011587329725">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I may be overthink this. I was hoping for an easy way to extend the ThreadPerTaskExecutor like the ThreadPoolExecutior is extensible. But I Agree in this case that it should wrap another executor as getting threading correct is hard! For the Executor Service,
Execute and Submit would he easy to manage, as it is a single task so easy to get a acquire a single resource from a semaphore. But I will need to be more careful around invokeAll and invokeAny, as I may need to acquire more permits than are available or one
invoke all may block another invoke from executing in parallel. So maybe I can submit them one at time, or just go ahead and get the number of permits at once.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
It is good to know that i dont need to use any jdk.internal classes. I saw both ThreadPerTaskExecutor and ThreadPoolExecutor using ThreadContainer and i wasn't sure if it was some special class to manage threads. I can implement something without this.</div>
</div>
</div></blockquote></div></div>