Thread starvation happens when thread does not enough CPU for its execution.
Thread starvation may happen in following scenarios >
- Low priority threads gets less CPU (time for execution) as compared to high priority threads. Lower priority thread may starve away waiting to get enough CPU to perform calculations.
- In deadlock two threads waits for each other to release lock holded by them on resources. There both Threads starves away to get CPU.
- Thread might be waiting indefinitely for lock on object’s monitor (by calling wait() method), but notify() may be repeatedly awakening some other threads. In that case also Thread starves away to get CPU.
/** JavaMadeSoEasy.com */