Java ReentrantLock.unlock/await()/signal() not throwing IllegalMonitorStateException
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Where am I going wrong? Even though my consumer Thread is not holding the lock, the program is not throwing IllegalMonitorStateException for any of the lock calls (unlock/await/signal). Update: private final ReentrantLock lock = new ReentrantLock(); private final Condition producers = lock.newCondition(); private final Condition consumers = lock.newCondition(); @Override public void run() { while (true) { try { //lock.lockInterruptibly(); try { while (sharedResource.isEmpty()) { printErr(name + " : Queue Empty .."); consumers.await(500,