Can notify wake up the same thread multiple times?
问题 Imagine you have a typical producer-consumer pattern in Java. To be a bit more efficient you want to use notify() and not notifyAll() when a new element is added to the queue. If two producer threads invoke notify, is it guaranteed that two distinct waiting consumer threads will be awoken? Or can it be that two notify() s fired shortly after each other cause the same comsumer thread to be queued for wakeup twice? I can't find the section is the API describing how this exactly works. Does java