Deadlock, livelock and diagnostics question 141 of 180 mid
What is starvation, and what causes it in a JVM?
- A thread with too little heap
- Correct: A thread that never gets the resource: barging locks, hogging tasks, endless readers
- A pool with no idle threads
- A GC pause
Starvation is progress denied indefinitely to one thread while others proceed. The usual causes: an unfair lock where arriving threads barge ahead of the queue; long-running tasks in a small pool leaving no slot for others; a write lock behind a continuous stream of readers; and thread priorities, which are a hint the OS may ignore entirely and should never be used as a correctness mechanism.
Thread starvation deadlock is the variant worth naming separately: every thread in a pool waits for a task that can only run on that same pool. Nothing is BLOCKED, no cycle exists, and the pool is simply dead.
Fair locks and bounded task durations are the fixes; fairness costs throughput, so it is a trade you make deliberately.
Quiz yourself on Deadlock, livelock and diagnostics Suggest a correction