Friday, March 13, 2015

IllegalMonitorStateException

java.lang.IllegalMonitorStateException

IllegalMonitorStateException is described in the javadoc comments as:

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.
author: unascribed version: 1.12, 12/19/03 see: java.lang.Object#notify() see: java.lang.Object#notifyAll() see: java.lang.Object#wait() see: java.lang.Object#wait(long) see: java.lang.Object#wait(long, int) since: JDK1.0

Where is this exception thrown?

Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.

How is this exception thrown?

The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.

Any source code quoted in this section is subject to the Java Research License unless stated otherwise.

java.util.concurrent.locks.AbstractQueuedSynchronizer.fullyRelease(Node)

/**
     * Invoke release with current state value; return saved state.
     * Cancel node and throw exception on failure.
     * @param node the condition node for this wait
     * @return previous sync state
     */
final int fullyRelease(Node node) {
    try {
        int savedState = getState();
        if (release(savedState)) return savedState;
    } catch (RuntimeException ex) {
        node.waitStatus = Node.CANCELLED;
        throw ex;
    }
    node.waitStatus = Node.CANCELLED;
    throw new IllegalMonitorStateException();
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

No comments:

Post a Comment