Answers

Question and Answer:

  Home  Java Multi-Threading

⟩ Explain the difference between yielding and sleeping?

Sleep causes the currently executing thread to sleep until the specified time is completed. The thread will resume once the specified time period is over.

Sleep causes the currently executing thread to sleep and gives a chance to other threads to execute. The thread will join the ready queue.

Thread.sleep() will moves the thread to “Wait” state.

Thread.yield() will moves the thread to “Ready” state.

 136 views

More Questions for you: