IllegalMonitorStateException

java, multithreading

Solution

The details must be given when the Exception is created (Constructor, right?) and if you are not creating it, there is no way for you to provide the details.

You can analize the StackTrace of the Exception. It shows the classes, methods and souce line which were called to cause the Exception.

One cause for the `IllegalMonitorStateException` is trying to wait on an Object without having synchronized on it. See the Javadoc.

There are other possible causes and the Exception may be thrown by some library/external code. I think only the StackTrace can help...

Problem

When running our program we get an exception of type java.lang.IllegalMonitorStateException. On Java6 API website, it says there is a constructor that gives a details about the exception: IllegalMonitorStateException(String s) How can we use this to get a better idea of where the bug is in our code? Is there anything else we can do (besides lots of debugging which we're currently doing) to pinpoint the function or line that failed?

Original source