introduction
Multi-threading is both the focus and difficulty in programming. Before learning multi-threading, we must first figure out several concepts in designing multi-threading. The learning model adopted by Xiao Yuan for learning new things is to figure out the concepts first. And what is "xxx"? Next is what can "xxx" do? Finally, why is "xxx". Using this mode can help the little ape quickly obtain the essentials of the thing. Okay, let's not talk nonsense, let's get to the topic.
Introduction to several professional terms related to multithreading
process
What is a process? The definition given by Du Niang is: A process is a running activity of a certain data set of a program with a certain independent function. This concept is a bit difficult to understand. First come to the previous picture: the
above shows the process. In fact, the process refers to the program loaded into the memory by the computer. An application can run multiple processes at the same time; the process is also the one-time execution of the program, which is the system running the program. The basic unit; the process will also experience birth, old age, sickness and death. Of course, an application can also have multiple processes, typically integrated antivirus tools, such as Tencent Butler.
Thread
For this concept, many on the Internet are relatively vague. Some people say that a thread is the channel from the application to the CPU. For this understanding, Xiao Yuan said that he could not agree with it. Look at the definition given by Du Niang as: thread (English: thread) is the smallest unit that the operating system can perform operation scheduling. It is included in the process and is the actual operating unit in the process. A thread refers to a single sequential control flow in a process. Multiple threads can be concurrent in a process, and each thread executes different tasks in parallel.
parallel
Refers to two or more events occurring at the same time. A simple model is as follows:
Concurrent
Refers to two or more events occurring in the same time period. The simple model looks like this:
to sum up
The key concepts of multi-threaded learning have been basically understood clearly. The follow-up Xiaoyan will focus on learning other programming knowledge related to multi-threading, such as thread safety issues, thread communication of multi-threaded programs and other issues.