wait()
notify()
notifyAll()
throw "java.lang.IllegalMonitorStateException: current thread not owner" at runtime if they are not called from within the synchronized method or block.
That is the wait(), notify(), and notifyAll() methods should be called for an object only when the current thread has already locked the object's lock.
When a thread running in a synchronized method of an object is calling the wait() method of the same object, that thread releases the lock of the object and is added to that object's waiting queue.