CompletableFuture.defaultExecutor()

Alan Bateman Alan.Bateman at oracle.com
Fri May 20 07:46:51 UTC 2022


On 20/05/2022 01:58, Ben Manes wrote:
> Hi August,
>
> I am asking in the context of CompletableFuture.runAsync(r) and friends. As
> this defaults to using platform threads it can quickly exhaust the FJP
> (e.g. futures blocking on other futures). A common footgun would be removed
> if the default was changed to use virtual threads instead. I have seen this
> surprise developers both in the context of Caffeine (AsyncCache) and
> work-related projects. I suspect this change is the team's plan, but I have
> not seen it discussed explicitly before. I do hope to switch Caffeine's
> default executor setting when appropriate, since cache loads are
> commonly I/O operations.
This project is focused right now on code written in the synchronous 
style. So no plans at this time to touch the FJ common pool. Code using 
the common pool (CompletableFuture and others) can of course using 
FJP.ManagedBlocker when doing blocking operations. One area of future 
investigation may be a concurrent equivalent to parallel streams that 
uses virtual threads but this is not for the JEPs that are currently in 
progress.

-Alan


More information about the loom-dev mailing list