In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains why java executes the run () method when calling the start () method. The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn why java executes the run () method when calling the run () method.
This is another classic java multithreaded interview question that is often asked during the interview. Very simple, but many people will not be able to answer!
New a Thread, the thread enters the new state; calling the start () method starts a thread and puts it into the ready state, and when the time slice is allocated, it can start running. Start () performs the corresponding preparation of the thread and then automatically executes the contents of the run () method, which is really multithreaded work. Executing the run () method directly will execute the run method as a normal method under a main thread, not in a thread, so it's not multithreaded.
Summary: calling the start method starts the thread and puts it into a ready state, while the run method is just a normal method call to thread or executed in the main thread.
Thank you for reading, the above is the content of "Why java executes the run () method when calling the start () method". After the study of this article, I believe you have a deeper understanding of why java will execute the run () method when calling the start () method, and the specific usage still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 269
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.