Comparision Between yield(), join(), sleep()

Propertyyield()join()sleep()
PurposeIf a Thread wants to pass its execution to give the remaining Thread the same priority, then. We should go for yield().If a Thread wants to wait until the completion of some other Thread, then we should go for join().If a Thread doesn’t want to perform any operation for a particular amount of time then we should go to sleep()
Is it overloaded?NoYesYes
Is it final?NoYes
No
Is it throws an Interrupted Exception?NoYesYes
Is it native?YesNosleep(long ms) native
sleep(long ms, int ns) nonnative
Is it static?YesNoYes

Similar Java Tutorials

Leave a Comment