I am currently studying threads and synchronization. What I have not been able to figure out a detail in the difference between notify and notifyAll.
I read that notifyAll() notifies all the threads that are waiting, and that notify() notifies only one thread waiting. I have no problem understanding who notifyAll() works.
- What if I call notify() and there are several threads waiting?
* How would the system determine what thread must be notified?
* Would it be an error to call notify() if there are several threads waiting?
Thanks in advance for your feedback!!
-Juan Carlos
I read that notifyAll() notifies all the threads that are waiting, and that notify() notifies only one thread waiting. I have no problem understanding who notifyAll() works.
- What if I call notify() and there are several threads waiting?
* How would the system determine what thread must be notified?
* Would it be an error to call notify() if there are several threads waiting?
Thanks in advance for your feedback!!
-Juan Carlos