- The sleep method would change the thread to sleep for the amount of time as passed in the parameter. E.g. sleep(1000) would cause the Thread to sleep for 1 second.
- The wait method would cause the Thread to sleep for the amount of time passed as the parameter, but the Thread could wake up early if it recieves the notify() or notifyAll() method. E.g. if we call the method wait(1000) the Thread goes into sleep for 1 second, but might wake up in 0.5 seconds if it recieves a notify() or notifyAll() call.
- The yield method changes the state of the object from running to runnable state.
Sunday, April 10, 2011
In Java Threads what is difference between the methods sleep, yield and wait ?
Labels:
Intermediate,
Java - Threads
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment