Fork/join and parallel streams question 111 of 180 senior
What happens if a fork/join task blocks on I/O?
- The pool creates a replacement thread automatically
- Correct: The worker is stuck, its deque is unavailable except to stealers, and with enough blocked workers the pool stops making progress;
ManagedBlockeris the escape hatch - The task is rescheduled
- Nothing, fork/join is designed for 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.
Quiz yourself on Fork/join and parallel streams Suggest a correction