Starvation occurs when a thread is unfairly blocked and fails to obtain execution time or a required shared resource. In a lock-based application, one thread may be preferred while another waits repeatedly instead of executing. section 7.2
Investigate starvation by asking:
- Do threads receive similar active CPU time and acquire a shared lock roughly equally often? section 7.2
- Does sampling show a method waiting on itself, suggesting that its thread is locked? section 7.4
Producer and consumer sharing a list
Two threads use one list and cannot work on it simultaneously. If the producer and consumer are locked about 3,698 times each, the contention is balanced rather than starvation. If one thread is repeatedly preferred, reduce unnecessary consumer locking, let the producer work longer, add producer threads, or process values in batches. The right change depends on the application’s workload. section 7.2



