Quick revision
The short answer
Without an executor, supplyAsync runs the supplier on ForkJoinPool.commonPool(), unless the common pool's parallelism is below 2, in which case CompletableFuture creates a new thread for every task. The common pool is sized for CPU work, about one thread per core, and is shared by the whole JVM, including parallel streams, so blocking I/O on it starves every other user. For I/O we pass a dedicated executor sized for that work, or a virtual-thread-per-task executor, and we give its threads clear names so they show up in thread dumps.
What to remember
In this answer, we saw that supplyAsync without an executor uses ForkJoinPool.commonPool(), or a new thread per task when the common pool's parallelism is below 2, as on small containers. The common pool is sized for CPU work and shared by the whole JVM, including parallel streams, so blocking I/O on it starves unrelated code. For I/O we pass a dedicated executor sized to the dependency, or a virtual-thread-per-task executor, and name its threads so thread dumps show which dependency is stuck.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Without an executor, supplyAsync runs the supplier on ForkJoinPool.commonPool(), unless the common pool's parallelism is below 2, in which case CompletableFuture creates a new thread for every task. The common pool is sized for CPU work, about one thread per core, and is shared by the whole JVM, including parallel streams, so blocking I/O on it starves every other user. For I/O we pass a dedicated executor sized for that work, or a virtual-thread-per-task executor, and we give its threads clear names so they show up in thread dumps.
Why this question is asked
The no-argument supplyAsync is convenient, which is why it appears in so many code bases and tutorials. It is also behind many production slowdowns that are hard to trace, because the work runs on threads shared with code that has nothing to do with ours. Interviewers ask this to see whether we know where async work actually runs and how to choose a pool for it. In this answer, we will see which executor is used by default, how the common pool is sized, reproduce the starvation that blocking I/O causes, and then pass a proper executor with named threads.
1Which Executor Runs supplyAsync by Default
supplyAsync(supplier) and runAsync(runnable) have overloads that take an Executor. When we leave it out, CompletableFuture uses its default async executor. That is ForkJoinPool.commonPool(), a single pool that exists once per JVM, as long as the common pool's parallelism is at least 2. If the parallelism is 1, CompletableFuture instead uses an internal executor that starts a brand new thread for each task, because a single shared thread could too easily be blocked by one task.
Notice the 2-CPU case. Containers often have small CPU limits, and there the default behaviour is quite different from a developer laptop: every supplyAsync call creates a thread, which can surprise us when we expected a bounded pool.
2Why the Common Pool Is the Wrong Place for I/O
The common pool's default parallelism is the number of available processors minus one. That size is right for CPU work: with one thread per core, every core stays busy and there is no time lost switching between threads. It assumes the tasks compute and do not wait.
It is also shared. Parallel streams use it, many libraries use it, and every supplyAsync without an executor anywhere in the JVM uses it. When one piece of code puts blocking calls there, such as an HTTP request that takes 300 ms or a database query, a thread that could compute is sitting idle waiting for the network, and everyone else's tasks queue behind it.
- Our supplyAsync callsno executor given, so they land here
- Parallel streams
list.parallelStream()in any code - Librariesanything else using the common pool or default async
- ForkJoinPool.commonPool()about one thread per core, for CPU work
4 layers, from the top down. Step through them one at a time.
One pool, many unrelated users: blocking in one place slows all of them.
3Reproducing the Starvation
Here is a small demonstration on an 8-core machine, where the common pool has 7 threads. We start 7 blocking calls, then another part of the application submits a quick CPU task that also uses the default executor.
The cart task is slow even though it has nothing to do with the HTTP calls. All 7 workers are parked in socket reads, so the new task sits in the queue until one of them finishes its 2-second call. Parallel streams suffer too: their calling thread can do some of the work itself, but they lose the parallelism they were written for. In a real service, the symptom is that unrelated features get slower whenever one dependency is slow, which is very hard to diagnose without a thread dump.
4Passing a Dedicated Executor
For I/O work we pass our own executor, sized for what it does. A bounded pool of platform threads is sized from the target system's capacity, for example equal to the HTTP client's connection limit or the database connection pool. On Java 21 and later, a virtual-thread-per-task executor is often simpler: each task gets a cheap virtual thread, blocking costs almost nothing, and the real limit comes from the connection pool or a semaphore.
Notice that the common pool is now left to CPU work, and a slow inventory service can at most use up the inventory pool, not the whole JVM. That is the isolation we want: a problem in one dependency stays in that dependency's pool.
5Naming Threads So They Show in Thread Dumps
When a service slows down, a thread dump is often the first thing we look at. Threads named pool-3-thread-17 tell us nothing. Threads named inventory-io-17, all parked in a socket read, tell us immediately which dependency is the problem. The thread factories in the code above give every thread a prefix and a counter. Virtual threads have no name by default, so naming them through Thread.ofVirtual().name(...) helps in the same way.
So in a dump we can count how many inventory threads are stuck and in which call, without guessing which anonymous pool they belong to.
6Follow-up questions
Does the same default apply to thenApplyAsync and the other Async methods?
Yes. Every Async method without an executor argument uses the same default async executor, so thenApplyAsync(fn) also runs on the common pool, or on a new thread per task when the parallelism is below 2.
Can we just make the common pool bigger?
We can set the system property java.util.concurrent.ForkJoinPool.common.parallelism at startup, but that changes the pool for every user in the JVM and hides the real problem. A dedicated executor isolates the blocking work and documents it in the code.
Are virtual threads always the right executor for I/O?
They are a good default for blocking I/O, but they do not limit concurrency. Ten thousand virtual threads can still overwhelm a downstream service or wait on a 20-connection pool. Pair them with a connection pool limit or a semaphore, and keep CPU-heavy work on a bounded platform pool.
7Conclusion
In this answer, we saw that supplyAsync without an executor uses ForkJoinPool.commonPool(), or a new thread per task when the common pool's parallelism is below 2, as on small containers. The common pool is sized for CPU work and shared by the whole JVM, including parallel streams, so blocking I/O on it starves unrelated code. For I/O we pass a dedicated executor sized to the dependency, or a virtual-thread-per-task executor, and name its threads so thread dumps show which dependency is stuck.
Open with
If I do not pass an executor, supplyAsync uses CompletableFuture's default async executor, which is ForkJoinPool.commonPool(). There is one exception: if the common pool's parallelism is below 2, for example on a 2-CPU container where it is cores minus one, so 1, CompletableFuture creates a new thread for every task instead.
Then, if they want more
The common pool itself has about one thread per core, because it is designed for CPU-bound work, and it is shared by the whole JVM: parallel streams, libraries and every other supplyAsync without an executor.
So if I put blocking I/O there, say an HTTP call that takes 300 milliseconds, the few threads sit waiting on the network and everything else that uses the pool queues behind them. The symptom is that unrelated async tasks suddenly get slow when one dependency is slow, which is hard to diagnose.
For I/O I always pass an executor: either a fixed pool sized to the dependency, for example the HTTP connection limit or the database pool size, or on Java 21 and later a virtual-thread-per-task executor, combined with a connection limit.
And I give the threads clear names with a thread factory, like inventory-io, so in a thread dump I can see at once which dependency the stuck threads belong to.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 21
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- java.util.concurrent, package documentation, JLS chapter 17, Threads and Locks
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Which executor runs supplyAsync(supplier) when no executor is given, and why should you...": https://scrivio-interview-library.netlify.app/java/completable-future/e96ba8f883/