What is the purpose of the wait(), notify(), and notifyAll() methods?

What is the purpose of the wait (), notify (), and notifyAll() methods?

The wait() method makes the thread to halt, thus allowing other thread to perform.

The notify() method triggers back the thread in wait() state to ready state and the execution continues.

The notifyAll() method will trigger all the threads in wait() state to ready state and the execution of all threads continues. These threads will be performed based on the priority and the selection based on JVM.

notify()
Wakes up a single thread that is waiting on this object's monitor.

notifyAll()
Wakes up all threads that are waiting on this object's monitor.

wait()
Causes current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
Event-listener interface and an event-adapter class
An event-listener interface allows describing the methods which must be implemented...
What is the purpose of the enableEvents() method?
To enable a particular event of an object, the enableEvents() method is utilized...
Difference between the File and RandomAccessFile classes in Java?
The OS based file system services such as creating folders, files, verifying the permissions, changing file names etc...
Post your comment