[StructuredTaskScope] Poor man's "back pressure" ?

Attila Kelemen attila.kelemen85 at gmail.com
Mon Dec 15 20:50:38 UTC 2025


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).

Alan Bateman <alan.bateman at oracle.com> ezt írta (időpont: 2025. dec. 15.,
H, 21:32):

>
>
> On 15/12/2025 19:29, Attila Kelemen wrote:
> > If I'm understanding your problem correctly, then you can just use
> > semaphores to limit the number of concurrent actions.
> >
> There are a few other threads to the same topic in the archives. Using a
> ThreadFactory that limits concurrency is one of the options that others
> were trying out.
>
> -Alan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20251215/d4281a75/attachment.htm>


More information about the loom-dev mailing list