1. Process (Progress)
a process is a single execution activity on a computer by a stand-alone program. For example, running the QQ program, running in the MP3 player and so on. A process is started by running a program. Process-based multitasking is the task of allowing a computer to run multiple programs at the same time.
2. Threads (thread)
A thread is a smaller execution unit than a process and can be understood as a fragment of a program that executes in a process. a thread-based multitasking process is a program that can perform multiple tasks. For example, Thunder download software, when downloading a video from the network, the user can play downloaded video content before it is finished downloading, this is the existence of playing and downloading two threads.
3. Process and Thread differences:
Multiple tasks can be run concurrently in the operating system called multi-process, and multiple execution paths in an application ice method execution is called multithreading. The process and thread differences are as follows:
- each process has its own code and data space (process context), and the switching overhead between processes is large ;
- Multiple threads within the same process share the same large code and data space, each process has a separate run stack and program counter (PC), and the switching overhead between threads is small
In general, you may want to use multithreading in the following situations:
- The program needs to perform two or more tasks at the same time;
- The program needs to implement some tasks that need to wait, such as user input, file read and write operation, network operation, search, etc.
- When you need some programs that run in the background.
1. Why do I need multi-threading?
Multithreading is a multitasking concurrency that has the following advantages:
- Improve the application accordingly;
- Improve computer CPU utilization;
- Improve program Structure
Process and Thread differences