Saturday, 15 July 2017

What do you mean by thread starvation?

Answer.  When thread does not enough CPU for its execution Thread starvation happens.
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), because no other thread is calling notify()/notifAll() method on object. In that case, Thread 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.

No comments:

Post a Comment