java.lang.IllegalMonitorStateException: (m=null) Failed to get monitor for
Why may this happen? The thing is that monitor object is not null for sure, but still we get this exception quite often: java.lang.IllegalMonitorStateException: (m=null) Failed to get monitor for (tIdx=60) at java.lang.Object.wait(Object.java:474) at ... The code that provokes this is a simple pool solution: public Object takeObject() { Object obj = internalTakeObject(); while (obj == null) { try { available.wait(); } catch (InterruptedException e) { throw new RuntimeException(e); } obj = internalTakeObject(); } return obj; } private Object internalTakeObject() { Object obj = null;