Question: what is the difference between yield and sleep in java?
Answer: what's the difference between yield() and sleep()? If we say thread. sleep(1000) , that thread will sleep for 1000 milliseconds for sure, whereas with yield() there is no such guarantee. This is useful for thread scheduling, since the thread which calls yield() may very well selected immediately again for running.