What happens when wait () is called on an object that does not extend Thread or implements Runnable?


What happens when wait() is called on an object not extending Thread or implements Runnable?

This is such simple question but when I was asked by somebody I had OK but not exact answer. Any exact answers?

The java docs are pretty clear on this. It does as the names suggest, causes the current thread to wait until notify or notifyall is called on the object (by another thread). These methods are used to coordinate between Threads that need access to the same critical resources and need mutual exclusion. In depth discussion here.

Calling wait and notify on a Thread object only makes sense if that Thread is being used as the lock object, which would be unusual in my experience.