wait()
method can be called to have the currently running
thread wait for a notification.
java.lang.IllegalMonitorStateException: current thread not owner
(Note that this effects how the code is organized.)
notify()
or notifyAll()
to notify a waiting thread that it can continue.
notify()
will notify one thread that is
waiting on that object, but you don't know which one.
notifyAll()
will notify all
threads waiting on
that object.
wait()
releases all locks, but
sleep()
does not.