Comparison of yield(), join() and sleep() in Java
Comparison table yield(), join(), sleep()
property |
yield() |
join() |
sleep() |
purpose |
If a thread wants to pass its execution to give chance to remaining threads of same priority then we should go for yield() |
If a thread wants to wait until completing of some other thread then we should go for join() |
If a thread does not want to perform any operation for a particular amount of time, then it goes for sleep() |
Is it overloaded? |
NO |
YES |
YES |
Is it final? |
NO |
YES |
NO |
Is it throws? |
NO |
YES |
YES |
Is it native? |
YES |
NO |
sleep(long ms)->native & sleep (long ms, int ns)-> non native |
Is it static? |
YES |
NO |
YES |
Last Updated :
27 May, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy
Please go through our recently updated Improvement Guidelines before submitting any improvements.
This article is being improved by another user right now. You can suggest the changes for now and it will be under the article's discussion tab.
You will be notified via email once the article is available for improvement.
Thank you for your valuable feedback!
Please go through our recently updated Improvement Guidelines before submitting any improvements.
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.