Java Thread notify() methodThe notify() method of thread class is used to wake up a single thread. This method gives the notification for only one thread which is waiting for a particular object. If we use notify() method and multiple threads are waiting for the notification then only one thread get the notification and the remaining thread have to wait for further notification. SyntaxReturnThis method does not return any value. ExceptionIllegalMonitorStateException: This exception throws if the current thread is not the owner of the object's monitor. ExampleOutput: Starting of Thread-1 Starting of Thread-2 Starting of Thread-3 Thread-3...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