PrepZone Logo
PrepZone
Back to Java

Java · Easy

Difference between Thread.sleep() and Object.wait(). When to use which?

JavaCore JavaConcurrency

Answer preview

sleep(ms) — A static method of Thread. Pauses the current thread for the specified duration. Does not release any locks. The thread enters TIMED_WAITING and resumes automatically after the timeout.…