Why are the methods wait() and notify() defined in the Object class when they are used with Threads?

Rob Edmondson

The wait() and notify() methods are object-specific. The wait() method suspends the current thread of execution, and tells the object to keep track of the suspended thread. The notify() method tells the object to wake up the suspended threads that it is currently keeping track of. Since wait() and notify() are object specific, they must be used within code that is synchronized on the object in question.

It is also important to use state variables when using wait() and notify(), as threads can be woken up by conditions other than notify().

suspend() is similar to wait() but does not add the thread to an object's wait list.