Question: what is difference between sleep and yield methods in java?
Answer: sleep (long milliseconds , int nanoseconds) specifies milliseconds and nanoseconds as an argument. According to Oracle docs, Yield method temporarily pauses the currently executing thread to give a chance to the remaining waiting threads of the same priority to execute.