two methods in ClassX
and, there's a class ClassY
If threadA is runing in ClassY, it synchronize cx, invokes wait(), if threadB invokes waitUntilTrue(), it's now waiting, too. if threadC uses setValue(), and pass true (new value), threadC will just notify one thread, because it didn't use notifyAll(), cannot make sure whether threadA or threadB receive the notification.
People usually use notify() and ignore notifyAll() but I have a book it says notifyAll() is better than notify() and it mentions a phrase "miss notification", what does it mean? Is it ture? In the book, it says if there is only one thread waiting, notify() is OK, notifyAll() is OK but it uses more resource than notify(), that's a waste, but if there are more than one thread.
You have three possible cases :