Thread.sleep() is used for time-synchronization.
object.wait() is used for multi-thread-synchronization.
Thread.sleep(5000); // no synchronization needed
object.wait() is used for multi-thread-synchronization.
synchronized (lock) {
while (!condition) {
lock.wait(); // releases lock
}
}
synchronized (lock) {
lock.notify();
}