title: Java - when to use notify or notifyAll?
body: <p>Why does <code>java.lang.Object</code> have two notify methods - <code>notify</code> and <code>notifyAll</code>? It seems that <code>notifyAll</code> does at least everything <code>notify</code> does, so why not just use <code>notifyAll</code> all the time? If <code>notifyAll</code> is used instead of <code>notify</code>, is the program still correct, and vice versa? What influences the choice between these two methods?</p>