Key notify notifyAll
1 Notification In case of multiThreading notify() method sends the notification to only one thread among the multiple waiting threads which are waiting for lock. While notifyAll() methods in the same context sends the notification to all waiting threads instead of single one thread.
2 Thread identification As in case of notify the notification is sent to single thread among the multiple waiting threads so it is sure that which of those waiting thread is going to receive the lock. On other hand notifyAll sends notification to all waiting threads hence it is not clear which of the thread is going to receive the lock.
3 Risk factor In case of notify() method the risk of thread missing is high as notification is sent only single thread and if it misses that than no other thread would get notification and hence the lock. While in case of notifyAll as notification is to all the waiting threads and hence if any thread misses the notification, there are other threads to do the job.Hence risk is less.
4 Performance Memory and CPU drain is less as compare to notifyAll as notification is sent to single one thread so performance is better as compare to notifyAll. On other hand as the cost of no notification is dropped and notification is sent to all waiting threads the memory and CPU drain is more as compare to notify and hence performance of notifyAll is lesser.
5 Interchangeable In case of the notify() method as only single one thread is in picture hence no concept of thread Interchangeable is possible. While we should go for notifyAll() if all your waiting threads are interchangeable (the order they wake up doesnâTMt matter).