Quick revision
The short answer
A ThreadPoolExecutor has one shared queue that all its threads take from, which suits independent tasks such as requests or jobs, including ones that block. A ForkJoinPool gives every worker thread its own double-ended queue and lets idle workers steal from busy ones, which suits many small CPU-bound tasks that split into subtasks. ForkJoinPool is also what runs parallel streams and, by default, CompletableFuture's async methods, and the virtual thread scheduler uses a ForkJoinPool of its own internally.
What to remember
In this answer, we saw that ThreadPoolExecutor has one shared queue that any thread takes from, which suits independent and blocking tasks and gives us bounded queues and rejection policies, while ForkJoinPool gives each worker its own deque and uses work stealing, which suits many small CPU-bound tasks that split into subtasks. ForkJoinPool's common pool runs parallel streams and default CompletableFuture async work, and a separate ForkJoinPool schedules virtual threads, so we keep blocking work off the common pool and choose each pool by the shape of the work.
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.
A ThreadPoolExecutor has one shared queue that all its threads take from, which suits independent tasks such as requests or jobs, including ones that block. A ForkJoinPool gives every worker thread its own double-ended queue and lets idle workers steal from busy ones, which suits many small CPU-bound tasks that split into subtasks. ForkJoinPool is also what runs parallel streams and, by default, CompletableFuture's async methods, and the virtual thread scheduler uses a ForkJoinPool of its own internally.
Why this question is asked
Java has two general-purpose thread pools, and they are built for different kinds of work. Choosing the wrong one does not usually break anything immediately; it shows up later as poor parallel speed-up or as a pool where threads sit blocked while work waits. Interviewers ask this question because the answer shows whether we know how each pool hands out work, and why that matters. In this answer, we will recap the shared-queue design of ThreadPoolExecutor, see how ForkJoinPool differs, look at where the JDK already uses ForkJoinPool for us, and then decide when to choose each.
1A Quick Recap of ThreadPoolExecutor
A ThreadPoolExecutor has a set of worker threads and one work queue, a BlockingQueue that every task goes into. Each worker loops: take a task from the queue, run it to completion, take the next. Because all workers take from the same queue, any free worker can pick up any task, and the order is simple, usually first in, first out.
This design is a good match for independent tasks of any size: handling a request, sending an email, running a report. It also tolerates blocking. If a task waits for a database, its thread waits, and the other threads keep taking tasks. We size the pool for that, as we would for any I/O-bound work. The cost is that the single queue is a shared point that every submit and every take touches, which matters only when tasks are very small and very many.
2How ForkJoinPool Is Different
A ForkJoinPool is built for a different shape of work: one big task that splits itself into smaller tasks, which split again, until the pieces are small enough to compute directly. This is called divide and conquer. Such a computation creates thousands or millions of tiny tasks, and a single shared queue would become the bottleneck.
So each worker in a ForkJoinPool has its own double-ended queue, called a deque. When a task running on a worker forks a subtask, the subtask goes into that worker's own deque, with no shared lock. The worker takes its own newest tasks from the same end. When a worker has nothing to do, it steals a task from the other end of another worker's deque. This is work stealing: the pool balances itself without a central queue, and busy workers rarely interfere with each other.
| Aspect | ThreadPoolExecutor | ForkJoinPool |
|---|---|---|
| Queues | one shared BlockingQueue | one deque per worker, plus submission queues |
| Load balancing | any free thread takes the next task | idle workers steal from busy ones |
| Best for | independent tasks: requests, jobs | many small CPU tasks that spawn subtasks |
| Blocking in tasks | fine, size the pool for it | reduces parallelism unless ManagedBlocker |
| Task API | Runnable, Callable | RecursiveTask, RecursiveAction, plus Runnable |
| Bounded queue, rejection | yes, configurable | no bounded queue option for submissions |
Notice the different style. With ForkJoinPool we submit one task and it creates the rest from inside the pool. With ThreadPoolExecutor we submit each independent job ourselves.
3Where the JDK Already Uses ForkJoinPool
We often use ForkJoinPool without naming it. Parallel streams split their source into chunks and process them as fork/join tasks in ForkJoinPool.commonPool(), a single shared pool for the whole JVM whose parallelism is by default one less than the number of available processors. CompletableFuture.supplyAsync() and the other async methods without an executor argument also run on the common pool, unless its parallelism is below 2, in which case they use a new thread per task.
The virtual thread scheduler is a ForkJoinPool too, but a separate instance, not the common pool. It runs in FIFO mode and has about one carrier thread per core; virtual threads are mounted on those carriers to run and unmounted when they block. Check your JDK version for its exact settings, which can be changed with the jdk.virtualThreadScheduler system properties.
The lesson is that the common pool is shared by parallel streams and async callbacks across all libraries in the application, so blocking work submitted there affects everyone.
4When to Choose Each
We choose ForkJoinPool for CPU-bound work that splits recursively: sorting or summing large arrays, processing a tree, searching a large space. Its tasks should not block, because a blocked worker is a core doing nothing, and the pool does not add threads unless the blocking goes through ForkJoinPool.managedBlock. For this kind of work, a dedicated ForkJoinPool or a parallel stream is usually right.
We choose ThreadPoolExecutor for independent tasks, especially blocking ones: calling services, talking to databases, running jobs from a queue. It gives us a bounded queue, a rejection policy, and a size we can tune for I/O. On Java 21 and later, for blocking work we can often use virtual threads instead, with an explicit concurrency limit per resource, and keep a small ThreadPoolExecutor for CPU-heavy tasks.
5Follow-up questions
Can a ForkJoinPool run ordinary Runnable tasks?
Yes. It implements ExecutorService, so submit() and execute() accept Runnable and Callable, and it can work well for many small independent asynchronous tasks, especially in FIFO mode. It just offers no bounded queue or rejection policy, which is why services usually prefer ThreadPoolExecutor for request-style work.
Why is the common pool's parallelism one less than the number of cores?
Because the thread that starts a parallel stream or calls join also does work. With 8 cores, 7 common pool workers plus the calling thread keep 8 cores busy.
What does work stealing give you that a shared queue does not?
Less contention, because workers push and pop their own deques without touching a shared lock, and automatic balancing of uneven work, because an idle worker takes the oldest, usually largest, task from a busy worker instead of waiting.
6Conclusion
In this answer, we saw that ThreadPoolExecutor has one shared queue that any thread takes from, which suits independent and blocking tasks and gives us bounded queues and rejection policies, while ForkJoinPool gives each worker its own deque and uses work stealing, which suits many small CPU-bound tasks that split into subtasks. ForkJoinPool's common pool runs parallel streams and default CompletableFuture async work, and a separate ForkJoinPool schedules virtual threads, so we keep blocking work off the common pool and choose each pool by the shape of the work.
Open with
The main difference is how work is handed out. A ThreadPoolExecutor has one shared blocking queue; every task goes in, and any free thread takes the next one.
Then, if they want more
That fits independent tasks like requests, jobs or emails, including tasks that block, and it gives us a bounded queue and a rejection policy. A ForkJoinPool gives each worker thread its own double-ended queue.
When a task forks a subtask, it goes into the current worker's deque with no shared lock, the worker processes its own newest tasks first, and idle workers steal the oldest tasks from other workers' deques.
That design is made for divide and conquer, many small CPU-bound tasks that spawn subtasks, like summing or sorting a large array, where a single queue would be a bottleneck.
ForkJoinPool is also everywhere in the JDK: the common pool runs parallel streams and CompletableFuture's async methods when we do not pass an executor, and the virtual thread scheduler is its own separate ForkJoinPool.
So I choose ForkJoinPool, or a parallel stream, for CPU-bound recursive work, and I avoid blocking inside it, because a blocked worker is a lost core unless the code uses ManagedBlocker. For blocking or independent work I use a bounded ThreadPoolExecutor, or on Java 21 and later virtual threads with an explicit limit on the downstream resource.
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 "What is the difference between ForkJoinPool and a regular ThreadPoolExecutor, and when...": https://scrivio-interview-library.netlify.app/java/executors/f7e04f8d6b/