Originally posted by Lavanya Raguram:
so do u mean when a currently running thread invokes wait on any object the current thread waits until it gets notify message from the corresponding object on which it called notify?
i am really confused in this part
When the currently running thread invokes wait() on any object, it will release the lock(s) of the object (note: this lock may be grabbed multiple times), and then wait for notifications on that object. At this point, it is no longer the currently running thread.
At some point later, a different thread (which is the currently running thread) will call notify() on the same object -- which can wake up this object. (or it can wakeup some other thread also waiting on the same object)
Once this thread is awoken, it is still blocked -- as it still needs to reacquire the lock(s) that it had given up eariler. Once that is done, it will return from the wait() method.
Henry