wait(), notify().
obj.wait() will release the object’s lock, until some other thread calls obj.notify(). When calling obj.wait(), current thread should own obj. Normally, it is called like:
synchronized(obj) { // acquire obj
obj.wait();
}
IllegalMonitorStateException will be thrown if current thread doesn’t own obj.
obj.notify() wakes up single thread which waits for obj lock.
obj.notifyAll() wakes up all thread which wait for obj lock. But they will compete for the lock.
sleep() will still hold the lock.
https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait–