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

Comparing HashSet and TreeSet Collections in Java

How Can We Improve the Performance of IdentityHashMap in Java ?

What is Volatile Keyword in Java ?

How Will You Pass Information From One JSP to Another JSP ?

How Can We Prevent a Deadlock in Java ?