What is Starvation?

Technology CommunityCategory: ConcurrencyWhat is Starvation?
VietMX Staff asked 4 years ago

Starvation describes a situation where a thread is unable to gain regular access to shared resources and is unable to make progress. This happens when shared resources are made unavailable for long periods by “greedy” threads or threads with more “prioroty”. For example, suppose an object provides a synchronized method that often takes a long time to return. If one thread invokes this method frequently, other threads that also need frequent synchronized access to the same object will often be blocked.

One more real live example may be this one. Imagine you’re in a queue to purchase food at a restaurant, for which pregnant women have priority. And there’s just a whole bunch of pregnant women arriving all the time. You’ll soon be starving.