Scrivio Interview library
DebuggingIntermediate7 min read · updated 12 November 2026

A service hangs under load. The thread dump shows no Java-level deadlock, but all 16 threads of the report-pool are WAITING in FutureTask.get, and the pool's queue contains subtasks submitted by those same threads. Explain.

This is a thread pool starvation deadlock: each of the 16 tasks running in report-pool waits in FutureTask.get for a subtask it submitted to the same pool, but those subtasks sit in the queue because all 16 threads are busy waiting. jstack's deadlock detector only looks for cycles of monitors and ownable synchronizers such as ReentrantLock, not for threads waiting on futures, so it reports nothing. We fix it by running subtasks on a separate pool or not blocking inside pool tasks, for example with CompletableFuture composition or ForkJoinPool, whose join can run other tasks while waiting; with a virtual thread per task there is no fixed pool to exhaust at all.

Why this question is asked

This is one of the most confusing hangs to diagnose, because every tool says nothing is wrong: no deadlock found, no CPU used, no errors in the logs, and yet nothing moves. It appears in report generation, batch jobs and any code that splits work into subtasks on the same executor, and usually only under load. Interviewers ask about it because it tests whether we understand what a deadlock is, rather than only what the JVM can detect. In this answer, we will recap how a ThreadPoolExecutor runs tasks, reproduce the hang, read the dump, explain why no deadlock is reported, and then go through the fixes.

1A Quick Recap of How a Fixed Pool Runs Tasks

A fixed thread pool, such as one from Executors.newFixedThreadPool(16), has 16 worker threads and a queue. When we submit a task, an idle worker runs it; if all 16 are busy, the task waits in the queue until a worker finishes its current task and takes the next one. A worker never runs two tasks at once and never puts a task aside to run another.

Future.get() blocks the calling thread until the task behind the future completes. When the caller is itself a worker of the pool, that worker is now blocked and unavailable for anything else, including the task it is waiting for.

2Reproducing the Hang

Here is the pattern from the question in a small form. Each report task splits its work into two parts, submits them to the same pool and waits for both.

Java
ExecutorService reportPool = Executors.newFixedThreadPool(16, Thread.ofPlatform().name("report-pool-", 1).factory());
Report build(long id) throws Exception {
Future<Part> header = reportPool.submit(() -> loadHeader(id)); // subtask on the same pool
Future<Part> lines = reportPool.submit(() -> loadLines(id));
return new Report(header.get(), lines.get()); // the worker blocks here
}
// light load: 3 reports -> 3 workers wait, 6 subtasks run on the other 13 workers -> fine
// heavy load: 16 reports at once -> 16 workers wait, 32 subtasks sit in the queue -> hangs forever
for (long id : ids) reportPool.submit(() -> build(id));
Step throughHow the pool starves itself
  1. 16 report tasks startthey occupy all 16 workers
  2. Each submits 2 subtasks32 subtasks join the queue
  3. Each calls future.get()all 16 workers are now WAITING
  4. Is any worker free to run a subtask?
    YesSubtasks run and parents finishNoNothing runs; the service hangs

4 steps in order. Play them, or step through them one at a time.

Notice why it works in testing. With a few reports, free workers run the subtasks and the waiting tasks finish. Only when the number of parent tasks reaches the pool size do all workers end up waiting, and from then on no worker is left to take a subtask from the queue. The pool is full of threads waiting for work that only the pool can do.

3Reading the Thread Dump

The dump shows all 16 workers in the same place, parked inside FutureTask.get, and no deadlock section at the end.

Java
"report-pool-7" #41 prio=5 os_prio=31 tid=0x... nid=0x... waiting on condition
java.lang.Thread.State: WAITING (parking)
at jdk.internal.misc.Unsafe.park(Native Method)
- parking to wait for <0x000000071a3e8c10> (a java.util.concurrent.FutureTask)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:...)
at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:...)
at java.util.concurrent.FutureTask.get(FutureTask.java:...)
at com.acme.reports.ReportService.build(ReportService.java:24)
# ... the same stack for all 16 workers; no "Found one Java-level deadlock" section

The clue is the combination: every worker of one pool waiting on a future, and, if we check the executor's metrics or take a heap dump, a non-empty queue holding the subtasks. That is the full cycle: workers wait for queued tasks, and queued tasks wait for workers.

4Why No Deadlock Is Reported

The JVM's deadlock detection, used by jstack and ThreadMXBean.findDeadlockedThreads(), follows ownership. It knows which thread owns each monitor and each ownable synchronizer, such as a ReentrantLock or ReentrantReadWriteLock, and it looks for a cycle where each thread waits for a lock owned by the next. A future has no owner in that sense. The thread waiting in FutureTask.get is waiting for a task to complete, and that task is not yet assigned to any thread; it is sitting in a queue. There is no ownership edge for the detector to follow, so it finds no cycle.

So this is a deadlock in the true sense, a set of threads that wait for each other forever, but one built from a resource the JVM does not track: the pool's capacity. Semaphores, connection pools and latches have no owner either.

5Fix 1: Separate Pools, or Do Not Block Inside the Pool

The simplest fix is to give subtasks their own pool, so that parents waiting in report-pool can never take the capacity that subtasks need. Now the worst case is that parents wait while subtasks run in the other pool.

Java
ExecutorService reportPool = Executors.newFixedThreadPool(16); // parents
ExecutorService loaderPool = Executors.newFixedThreadPool(32); // subtasks only, never submits to itself

The rule that makes this safe is that loaderPool tasks never submit to loaderPool and wait; otherwise the same starvation moves one level down.

6Fix 2: Compose Instead of Waiting, or Let Waiting Help

Better still is not to block at all. With CompletableFuture we describe what should happen when both parts are ready, the parent never waits, and the result is assembled on whichever thread finishes last.

Java
CompletableFuture<Report> build(long id) {
var header = CompletableFuture.supplyAsync(() -> loadHeader(id), reportPool);
var lines = CompletableFuture.supplyAsync(() -> loadLines(id), reportPool);
return header.thenCombine(lines, Report::new); // no thread blocks waiting
}

ForkJoinPool takes a different approach that suits divide-and-conquer work. When a task in a ForkJoinPool calls join() on a subtask it forked, the worker does not simply park: it can run the subtask itself if no one has started it, or run other queued tasks while it waits. That is called work stealing and helping, and it means a pool of parents and children can make progress even when every worker is joining. It suits CPU-bound splitting, not blocking I/O.

Finally, with virtual threads the problem changes shape. If each report and each subtask gets its own virtual thread, for example through Executors.newVirtualThreadPerTaskExecutor(), there is no fixed number of workers to exhaust, so blocking in get() is cheap and harmless. Any remaining limit, such as database connections, then has to be explicit, and the same starvation can reappear if a parent holds a limited resource while waiting for children that need it.

7Follow-up questions

Would a bigger pool fix it?

It moves the threshold but does not remove the problem. With 64 threads, the hang appears when 64 parents run at once. The fix has to remove the dependency of tasks on capacity they themselves occupy.

How can I detect this automatically in production?

Monitor each executor's active count, pool size and queue size. A pool where active equals pool size, the queue is not empty, and completed task count stops increasing for a minute is stuck. Alerting on that pattern catches starvation that the deadlock detector cannot.

Does the common ForkJoinPool have the same risk with parallel streams?

Blocking I/O inside parallel streams or CompletableFuture tasks on the common pool can exhaust its few workers, which are one fewer than the number of cores by default, and slow everything else that uses it. The usual advice is to give blocking work its own executor and keep the common pool for short CPU-bound work.

8Conclusion

In this answer, we saw that a fixed pool whose tasks block waiting for subtasks submitted to the same pool hangs as soon as all workers are parents: every thread waits for queued work that only those threads could run. jstack reports no deadlock because its detector follows owners of monitors and ownable synchronizers, and a future in a queue has no owner. We fix it with a separate pool for subtasks, by composing futures instead of blocking, with ForkJoinPool's helping join for divide-and-conquer work, or with a virtual thread per task, which removes the fixed pool altogether.

What to say in the interviewAbout 90 seconds aloud

Open with

This is a thread pool starvation deadlock. Each of the 16 report tasks submitted subtasks to the same report-pool and then called get on their futures. Once 16 parents are running, every worker is blocked in FutureTask.get, and the subtasks they are waiting for are sitting in the queue, because there is no free worker to run them.

Then, if they want more

So workers wait for queued tasks and queued tasks wait for workers, forever. Under light load it works, which is why it shows up only under load. The thread dump does not say deadlock because jstack's detector follows ownership: it finds cycles where threads wait for monitors or ownable synchronizers like ReentrantLock owned by other threads.

A future that is still in a queue is not owned by any thread, so there is no edge to follow. The clue is all workers of one pool parked in FutureTask.get with a non-empty queue.

To fix it, I would either run subtasks on a separate pool, so parents can never consume the capacity subtasks need, or stop blocking inside pool tasks, for example by composing with CompletableFuture and thenCombine. For divide-and-conquer work, ForkJoinPool's join can run other tasks while it waits.

And with a virtual thread per task there is no fixed pool to exhaust, so blocking in get is fine.

About this answer

Last updated
12 November 2026
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.
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 "A service hangs under load. The thread dump shows no Java-level deadlock, but all 16...": https://scrivio-interview-library.netlify.app/java/concurrency-problems/0341850843/