posted 21 years ago
Hi,
I don't know if I understand your question correctly, but you must have an object associated with a thread and they will be in a wait state, just like when you synchronize, you synchronize on an object.
Here is an explanation for those terms maybe it will be clearer:
Wait : synchronized, will release the lock and do other process before it continues. Uses try-catch block exceptions. There is a wait method with a timeout in ms. After the time is exhausted, the Thread attempts to proceed but is allowed to do so only if no other Thread has a lock on the object. This method is handy when you are not sure that another Thread will be able to call notify, because it guarantees that the Thread will not be stuck in the wait state forever.
Notify : synchronized , when called, a Thread is removed from the wait set and returned to the list of Runnable Threads.
NotifyAll : synchronized, call if there is more than one thread waiting. This removes all waiting threads from the wait list. Only one of these actually get the lock on the object and is allowed to execute the synchonized method; the others run and find that the object is still locked.
If a thread has a lock on one or more objects dies, the JVM removes the locks and does the equivalent of notifyAll for each object locked.