What is the Difference Between Sleep and Wait Methods in Java ?

In Java, we use these methods to pause currently running thread. There is a simple difference between these.

sleep() is actually meant for short pause because it doesn't release lock.

wait() is meant for conditional wait and it can release a lock that can be acquired by another thread to change the condition on which it is waiting.



You May Interest

Why Integer Class in Final in Java ?

What is the Difference Between Throw and Throws in Java ?

When is UnsupportedOperationException Thrown in Java ?

What is the Reason For Overriding equals Method in Java ?

What is a CAS Operation in Java ?