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

Windows 7 - STOP 0x0000007B (0xFFFFF880009A97E8 0xFFFFFFFFC0000034 0x0000000000 0x0000000000)

If you encounter STOP 0x0000007B (0xFFFFF880009A97E8 0xFFFFFFFFC0000034 0x0000000000 0x0000000000) blue screen of death. This is very like...