Writer starvation

Writer starvation

The use of notifyAll() ensures that when a writer finishes both waiting readers and writers are awakened. The program relies on Java having a fair scheduling strategy among threads of equal priority to let readers and writers have a chance of running when a writer finishes.

However, in the situation when readers continually access the shared resource, [readers>0] writer threads never get the chance to access the shared resource.

The solution to avoiding writer starvation is to make readers defer if there is a writer waiting.

Previous slide Next slide Back to the first slide View Graphic Version