Is the main function the main thread?

Source: Internet
Author: User

Is the main function the main thread?
1. Thread concept:

A thread is the most basic unit of running a program, but a process cannot run. Therefore, a thread in a process can run.

 

 

2. How to Create a thread:

A process is just a container that contains the data structure and other information required for thread running. When a process is created, the operating system creates a thread, which is the main thread. Other slave threads are created by the code of the main thread, that is, the programmer.

When a program starts, a process is created by the operating system (OS), and a Thread runs immediately. This Thread is usually called the Main Thread of the program ), it is executed at the beginning of the program. If you need to create another thread, the created thread is the subthread of the main thread. Each process has at least one main thread. In Winform, it should be the thread for creating the GUI. The importance of the main thread is reflected in two aspects: 1. It is the thread that generates other sub-threads; 2. It usually has to complete the execution at last, such as executing various close actions.

 

 

3. is the main function a process or a thread:

Because they all start to run with main () as the entry. Is a thread and a process at the same time. In the current operating system, all are multi-threaded. However, when it is executed, it is an independent process. This process can contain multiple threads or only one thread. When a program is written in c, a process in the operating system contains a thread. When a multi-threaded program is developed using java, it plays a process in the operating system, but it can contain multiple concurrent threads.

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.