Java Concurrency Interview

Deadlock, livelock and diagnostics question 143 of 180 senior

Your service stops responding but CPU is at zero. What is your first hypothesis?

Zero CPU with no progress means nobody is running, so look for where they are all parked. The three usual shapes: a genuine deadlock cycle; a thread pool whose every worker is waiting on a slow or unresponsive dependency, with the queue growing behind it; or one lock held across an I/O call, with everyone else BLOCKED behind it.

The dump tells you which within a minute. A missing timeout is the root cause an embarrassing amount of the time: a socket read with no SO_TIMEOUT, a Future.get() with no bound, an HTTP client whose default is infinite.

High CPU with no progress is the opposite diagnosis: a livelock, a spin loop, or a GC death spiral, which you separate with jcmd GC.heap_info or a GC log rather than a thread dump.

diagnostics scenario

Quiz yourself on Deadlock, livelock and diagnostics Suggest a correction