- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between sleep() and wait() Method in Java
In this post, we will understand the difference between sleep and wait methods in Java.
Wait
It belongs to the ‘Object’ class.
This method releases the lock when synchronization is in process.
It is not a static method.
It is to be called only from a synchronized context.
This method has three overloaded methods, namely
wait()
wait(long timeout)
wait(long timeout, int nanoseconds)
Sleep
It belongs to the ‘Thread’ class.
It doesn’t release the lock on the object when synchronization is in process.
It is a static method.
From a synchronized context, there is no need to call the ‘sleep’ method.
This method has three overloaded methods, they are −
sleep(long millis)millis: milliseconds
sleep(long millis,int nanos) nanos: Nanoseconds
- Related Articles
- Difference between Wait and Sleep in Java
- Differences between wait() and sleep() method in Java?
- Difference Between Sleep and Hibernation
- Java Concurrency – sleep() method
- Difference between == and equals() method in Java.
- Difference between constructor and method in Java
- Differences between wait() and join() methods in Java
- Difference between Stop and Wait protocol and Sliding Window protocol
- Difference between Stop and Wait, GoBackN and Selective Repeat protocols
- What is the difference between java method and native method?
- What is difference between a Java method and native method
- What is the difference between method hiding and method overriding in Java?
- What is the difference between method overloading and method hiding in Java?
- What is the difference between method overloading and method overriding in Java?
- Difference between default and static interface method in Java 8.

Advertisements