Difference between notify and notifyAll in java
GIAN Tutorials
7:57 AM
notify(): When you call notify method on the object, it wakes one of thread waiting for that object. So if multiple threads are waiting for an object, it will wake of one of them. Now you must be wondering which one it will wake up. It actually depends on OS implementation. notifyAll() : notifyAll will wake up all threads waiting on that object unlike notify which wakes up only one of them.Which one will wake up first depends on thread priority and OS implementation. Lets understand it with the help of example: 1. Create a class named File.java: It is java bean class on which thread will act and call wait and notify method. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 package org . arpit . java2blog . thread ; public class File { String name ; boolean isCompleted ; public File ( String name ) { super ( ) ; this . name