What is the difference between yield and sleeping? What is the difference between the methods sleep() and wait()?
>> Monday, May 30, 2011
When a task invokes yield(), it changes from running state to runnable state. When a task invokes sleep(), it
changes from running state to waiting/sleeping state.
The method wait(1000), causes the current thread to sleep up to one second. A thread could sleep less than 1
second if it receives the notify() or notifyAll() method call. The call to sleep(1000) causes the current thread to sleep for exactly 1 second.
changes from running state to waiting/sleeping state.
The method wait(1000), causes the current thread to sleep up to one second. A thread could sleep less than 1
second if it receives the notify() or notifyAll() method call. The call to sleep(1000) causes the current thread to sleep for exactly 1 second.
0 comments:
Post a Comment