INTERTHREAD COMMUNICATION WAIT AND NOTIFYALL METHOD

Interthread Communication wait and notfiyAll method

Interthread Communication wait and notfiall method:
Multithreading replaces event loop programming by dividing your tasks into discreet
and logical units. Threads also provide a secondary benefit: they do away with
polling. Polling is usually implemented by a loop that is used to check some
condition repeatedly. Once the condition is true, appropriate action is taken. This
wastes CPU time.To avoid polling, Java includes an elegant inter-process
communication via wait(), notify() and notifyAll(). These methods are implemented as
final methods in Object, so all classes have them. All these three methods can be
called only from within a synchronized method. .

The method wait() tells the calling thread to give up the monitor and go to sleep
until some other thread enters the monitor and calls notify(). Additional forms of
wait() exist that allow you to specify a period of time to wait.
The method notify() wakes up the first thread that called wait() on the same object.
The method notifyAll() wakes up all the threads that called wait() on the same
object. The highest priority thread will run first.

About Java Padho

Einstein said, "It is the supreme art of the teacher to awaken joy in creative expression and knowledge." Great teachers are scarce, as they hold nothing back and give everything away. Javapadho is the brainchild of such an extraordinary teacher, i.e. Mr. Praveen Kumar Chandaliya, the founder of SDJ Infosoft.