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.