Resource Constrained Thread Per Task Executor

Attila Kelemen attila.kelemen85 at
Mon May 13 21:22:26 UTC 2024

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.

Colin Redmond <Colin.Redmond at> ezt írta (időpont: 2024. máj.
13., H, 23:05):

> 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.
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the loom-dev mailing list