Relative Content

Tag Archive for javamultithreadingsemaphorecounting-semaphore

Use of notifyAll instead of notify in the BoundedSemaphore implementation

Sample implementation of BoundedSemaphore found on Jenkov’s website uses notify instead of notifyAll in the take and release methods. In a scenario with multiple consumers and producers, wouldn’t this cause a producer to wake up another producer (similarly consumer thread may wake up another consumer thread) leading to missed signals? Does notifyAll make more sense or am I missing something?