A
wait
can be "woken up" by another thread calling
notify
on the monitor which is being waited on whereas a
sleep
cannot. Also, a
wait
(and
notify
) must happen in a block
synchronized
on the monitor object whereas
sleep
does not:
Object mon = ...;
synchronized (mon) {
mon.wait();
}
At this point, the currently executing thread waits and releases the monitor. Another thread may do
synchronized (mon) { mon.notify(); }