Object: Wait - Notify
Object
Avoiding sleep() and other inefficiencies with wait( ),
notify( ), and notifyAll( ):
In using the term monitor, one can
think of a controler.
- wait( ) - the calling thread gives up the monitor and go
to sleep until some other thread enters the same monitor and calls
notify( ).
- notify( ) - wakes up the first thread that called
wait( ) on the same object.
- notifyAll( ) - wakes up all the threads that called
wait( ) on the same object.
Notes:
- Using this technology, Threads can be given priority the highest running
first.
- There are timed versions of wait( ) , giving the period
of time to wait as an argument.