1: To understand multi-threading, you must first understand the thread, and to understand the thread, you must first understand the process, because the thread is dependent on the process and exists.
2: What is a process?
Through the Task Manager we see the existence of the process.
By observing, we find that only the running program will appear.
Process: Is the program that is running.
A process is an independent unit of system resource allocation and invocation. Each process has its own memory space and system resources.
3: What is the point of multi-process?
A single-process computer can do only one thing, and we now have computers that do multiple things.
Example: While playing the game (the game process), while listening to music (music process).
This means that computers now support multiple processes and can perform multiple tasks within a single time period.
And, you can increase the CPU utilization.
Problem:
Do you play the game while listening to the music at the same time?
No. Because a single CPU can only do one thing at a certain point in time.
While we are playing the game, or listening to music, the CPU is doing the program between the efficient switching let us feel that it is at the same time.
4: What is a thread?
Multiple tasks can be performed within the same process, and each of these tasks I can see is a thread.
Thread: is the execution unit of the program, the execution path. is the most basic unit of the CPU used by the program.
Single thread: If the program has only one execution path.
Multithreading: If the program has more than one execution path.
5: What is the point of multithreading?
Multithreading exists, not to improve the execution speed of the program. In fact, to improve application usage.
The execution of the program is actually in the grab CPU resources, CPU execution right.
Multiple processes are robbing this resource, and one of those processes has a higher chance of grabbing CPU execution if the execution path is more.
We are not sure which thread will be able to grab at any time, so the execution of the thread is random.
Overview of processes and Threads