Java thread start () and run () Methods

Source: Internet
Author: User

1. start () methodTo start the thread and realize multi-threaded running. In this case, you do not have to wait until the run method code is executed successfully and directly continue to execute the following code:
Start a Thread by calling the start () method of the Thread class,
This thread is in the ready state,
Not running.
Then, the Thread class calls the method run () to complete its operation,
Here the run () method is called the thread body,
It contains the content of the thread to be executed,
The Run method is finished,
This thread is terminated,
The CPU then runs other threads,

2. run () methodThe program must be executed in sequence as a normal method, or the following code can be executed after the run method is completed:
If you directly use the Run method,
This is just to call a method,
The program still has only the main thread-this thread,
There is only one program execution path,
In this way, the write thread is not achieved.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.