The wait() method is part of the java.lang.Object class, which means that any thread can call it. When you call wait(), your thread stops its execution until another thread invokes notify() or notifyAll().
When a thread calls the wait method on an object, it releases ownership of the object's monitor. After this, another thread can call the notify method on that object to wake up one or all of the threads waiting for it. A thread that wakes up returns control to the point where it waits.
Java's synchronized methods and blocks allow a program to control, which threads can acquire the lock on a resource at any given time. When wait() is called by a thread, it gives up the lock on that resource and goes to sleep, waiting for some other thread to invoke notify() or notifyAll().
The easiest way to make a Java program wait is by using the Thread. sleep() method. The sleep() method is present in the Thread class and pauses the current thread for a specific time.