Java Multi-Threading Question:
Download Questions PDF

Explain the difference between yielding and sleeping?

Java Multi-Threading Interview Question
Java Multi-Threading Interview Question

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 Interview Questions And Answers PDF

Previous QuestionNext Question
What the difference is between notify and notify All methods?Explain the difference between preemptive scheduling and time slicing?