Java Multi-Threading Question:

Explain the difference between yielding and sleeping?

Tweet Share WhatsApp

Answer:

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.

Download Java Multi-Threading PDF Read All 36 Java Multi-Threading Questions
Previous QuestionNext Question
What the difference is between notify and notify All methods?Explain the difference between preemptive scheduling and time slicing?