notify results in a single thread acquiring a lock whereas notifyAll results in all the threads competing for the lock and one of them acquiring it
so any way only one thread is able to acquire the lock, so why do we need notfyAll at all.
Is there something more to it.
Yes, there's a good reason to have notifyAll. notify will only wake one thread up, the others will still be waiting for something to happen. notifyAll will wake all threads up so that they know that something has happened (that is all threads will continue to execute when they can acquire the lock)
There is a difference whether all waiting threads are waken and compete for the lock or only one. Only one is able to acquire the lock at a given moment, but later on the two scenarios differ.