Difference between yield(), join(), sleep() method?

Comparison table of yield() and join() and sleep() method

No Property Yield() Join() Sleep()
1 Purpose If a thread wants to pause its execution to give the chance for remaining threads of same priority then we should go yield() method If a thread wants to wait until completing some other thread then we should go join() method If a thread don’t want to perform any operation for a particular amount of time then we should for sleep() method
2 Is it overloaded No Yes Yes
3 Is it final No Yes No
4 Is it throws IE Exception No Yes Yes
5 Is it native method Yes No Sleep(long ms):- Yes
sleep(long ms, int ns):- No
6 Is it static Yes No Yes

Leave a Reply

Your email address will not be published. Required fields are marked *