Grokking Multithreading and Concurrency for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Semaphores are not used properly

Junaed Halim

Oct 13, 2025

Your workers never use bufferNotEmpty[i]. They just lock each buffer and check isEmpty(). That turns bufferNotEmpty[i] into a no-op and also causes permit drift: producers keep calling bufferNotEmpty[i].release() but no one ever acquires those permits, so the semaphore count grows and no longer matches the true item count.

0

0

Comments
Comments

On this page