Home > DeveloperSection > Interviews > Point out difference between sleep() and wait() method in java

Posted on    September-10-2015 8:44 AM

 Java Java  Thread  Threading  Multiple Threading 
Ratings:
 1 Answer(s)
  521  View(s)
Rate this:

Mayank Tripathi
Mayank Tripathi

Total Post:807

Points:4035
Posted on    September-10-2015 8:44 AM

The code sleep(1000); puts thread aside for exactly one second. The code wait(1000), causes a wait of up to one second. A thread could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread.

Don't want to miss updates? Please click the below button!

Follow MindStick