Javatpoint Logo
Javatpoint Logo

Java Thread notifyAll() method

The 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.

Syntax

Return

This method does not return any value.

Exception

IllegalMonitorStateException: This exception throws if the current thread is not the owner of the object's monitor.

Example

Test it Now

Output:

Starting of Thread-1
Starting of Thread-2
Starting of Thread-3
Thread-3...notified
Thread-2...notified
Thread-1...notified






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA