Difference between notify and notifyAll in Java - When and How to use
notify vs notifyAll in Java What is the difference between notify and notifyAll method is one of th e tricky Java questions , w hich is easy to answer but once Interviewer asks follow-up questions, you either got confused or not able to provide clear-cut and to the point answers? The main difference between notify and notifyAll is that notify method will only notify o ne Thread a nd notifyAll method will notify all Threads which are waiting on that monitor or lock. By the way, this is something you have been reading in all over places and to be frank, this statement despite being correct is not complete and its very difficult to understand difference between notify vs notifyAll by just reading this statement. Lot of questions comes in mind like Which thread will be notified if I use notify() ? How do I know how many threads are waiting, so that I can use notifyAll() ? How to call notify()? What are these thread waiting for being notified etc? Actually, discussion of notify