What is the difference between a wait() and sleep() in Threads?
Is my understanding that a wait()-ing Thread is still in runni
From oracle documentation page on wait() method of Object:
public final void wait()
notify() method or the notifyAll() method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0).This method throws
IllegalMonitorStateException - if the current thread is not the owner of the object's monitor.
InterruptedException - if any thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
From oracle documentation page on sleep() method of Thread class:
public static void sleep(long millis)
This method throws:
IllegalArgumentException - if the value of millis is negative
InterruptedException - if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
Other key difference:
wait() is a non-static method (instance method) unlike static method sleep() (class method).