Java Thread notifyAll() methodThe notifyAll() method of thread class is used to wake up all threads. This method gives the notification to all waiting threads of a particular object. If we use notifyAll() method and multiple threads are waiting for the notification then all the threads got the notification but execution of threads will be performed one by one because thread requires a lock and only one lock is available for one object. SyntaxReturnThis method does not return any value. ExceptionIllegalMonitorStateException: This exception throws if the current thread is not the owner of the object's monitor. ExampleTest it NowOutput: Starting of Thread-1 Starting of Thread-2 Starting of Thread-3 Thread-3...notified Thread-2...notified Thread-1...notified Next TopicMultithreading Java |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India