Wednesday, May 5, 2010

IllegalMonitorStateException

Base on JavaDoc, IllegalMonitorStateException is thrown to indicate that a thread has attempted to wait on an object's monitor or to notify other threads waiting on an object's monitor without owning the specified monitor.

This can happens when you perform notify, notifyAll, wait method for an object, especially, when you are trying to perform cross thread notify and wait operation.

The way to solve this issue is to surround the object to be notified or wait with synchornized block


synchronized (obj) {
obj.wait();
}

No comments:

Post a Comment

Hadoop - How to setup a Hadoop Cluster

Below is a step-by-step guide which I had used to setup a Hadoop Cluster Scenario 3 VMs involved: 1) NameNode, ResourceManager - Host...