Originally posted by Ernest Friedman-Hill:
That exception is thrown when you try to call wait() or notify() without owning the monitor on the object. In other words, you can call these methods only inside a synchronized method of that same object, or in a synchronized block that locks that object.
This is the short answer... the longer answer is... you need to understand why this is so. The designers of
Java didn't require that the monitor be owned on a whim. There are some race conditions involved. Synchronizing the object will get you by this error message, but you still need to understand, and code it, so that you won't have the race condtion.
Henry