Java Threads Question:

Download Job Interview Questions and Answers PDF

What is the difference between yielding and sleeping?

Java Threads Interview Question
Java Threads Interview Question

Answer:

When a task invokes its yield() method, it returns to the ready state, either from waiting, running or after its creation. When a task invokes its sleep() method, it returns to the waiting state from a running state.

Download Java Threads Interview Questions And Answers PDF

Previous QuestionNext Question
What are three ways in which a thread can enter the waiting state?
Or
What are different ways in which a thread can enter the waiting state?
How to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state?
Or
Extending Thread class or implementing Runnable Interface. Which is better?