Difference between Semaphore and Condition (ReentrantLock)
问题 Does anyone know the differences between the methods acquire () and release () ( java.util.concurrent.Semaphore ) and await () and signal (new ReentrantLock().newCondition() ) . Can you expose a pseudo code for each of these methods? 回答1: Superficially the behavior of these method might look similar - acquire()/await() can make threads block in some cirsumstances and release()/signal() can unblock threads in some circumstances. However Semaphore and Condition serve different purposes: java