I wonder if it is possible to use Semaphore to implement blocking queue?
In the below codes, I use one Semaphore to protect the critical section, and two more Semaph
Without testing, I would say this works. However, every release() will notify the thread blocked in acquire(). So you really have at least the same cost as a reentrantlock+condition, likely worse because there is 2 acquire and 2 release() calls.