As my understanding, if I am thread then:
When I call
notifyAll() it means means I am sending a signal to other thread which
are waiting on this object monitor. Am I right?
But What the
Am I sending signal to other thread to wait so that I can complete my work on it?
I am declaring that I will wait, You do your work and tell me when you are done.?
I have a little concept about threads
No, it means you want to wait for a notification.
As per the Java docs (my emphasis):
Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
It means "I am declaring that I will wait, You do your work and tell me when you are done."
Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0). The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.
See this link