Sunday, 15 January 2017

What is starvation in Thread ?

Starvation
If a thread is not granted CPU time because other threads grab it, it is called "starvation". The thread is "starved to death" because other threads are allowed the CPU time instead of it. The solution to starvation is called "fairness" - that all threads are fairly granted a chance to execute.

Causes of Starvation in Java:
     Threads with high priority allow all CPU time from threads with lower priority

     Threads are blocked indefinitely waiting to enter a synchronized block


     Threads waiting on an object (called wait() on it) remain waiting indefinitely

No comments:

Post a Comment