What is the difference between yield() and sleep()?

yield() allows the current the thread to release its lock from the object and scheduler gives the lock of the object to the other thread with same priority.

sleep() allows the thread to go to sleep state for x milliseconds. When a thread goes into sleep state it doesn’t release the lock.

yield() method used to request to the jvm scheduler to set the same priority to all threds but it can’t force to jvm , can request n its depend on jvm to execute the thread.

sleep() method used to send a thread in sleep mode for a millisec but without releasing lock.

When a object invokes yield() it returns to ready state. But when an object invokes sleep() methodenters to not ready state.