Methods sleep-wait

Differentiate between the methods sleep() and wait()?

E

Expert

Verified

The sleep() method is used while the thread has to be placed aside for a fixed amount of time. Like: sleep(1000), puts the thread separately for just one second. The wait() method is used to put the thread separately for up to the indicated time. It might wait for much lesser time if it obtains a notify() or notifyAll() call. Like: wait(1000), causes a wait of approximately one second. The method wait() is defined in the Object and the method sleep() is defined in class Thread.

   Related Questions in JAVA Programming

©TutorsGlobe All rights reserved 2022-2023.