Question: what is the difference between yielding and sleeping?
Answer: Sleep holds the thread's execution for the specified time. When a task is invoked in yielding, it returns to the ready state. When a task is invoked in sleeping, it returns to the waiting state. It is used to get the running thread into out of runnable state with the same priority.