Java Concurrency Interview

Fork/join and parallel streams question 111 of 180 senior

What happens if a fork/join task blocks on I/O?

Fork/join is sized for CPU work, with roughly one thread per core, and its whole model assumes tasks finish quickly and often spawn subtasks. A worker blocked on a socket does none of that: it holds a thread, and the work it would have stolen goes undone. Block all of them and the pool is dead while the CPU sits idle.

ForkJoinPool.ManagedBlocker is the official escape. It tells the pool "I am about to block", and the pool may compensate by starting an extra thread. CompletableFuture's join and get use it internally.

The better answer in 2026 is that blocking work belongs on virtual threads or a dedicated pool, and fork/join should keep to what it was built for.

forkjoin performance

Quiz yourself on Fork/join and parallel streams Suggest a correction