Multithreading can process tasks in parallel, butThreads cannot exist alone. They are started and managed by processes
A process is a running instance of a program. The detailed explanation is that when starting a program, the operating system will create a block of memory for the program to store code, running data and a main thread executing tasks. We call such a running environmentprocess。
Threads are dependent on the process, and the use of multi-threaded parallel processing in the process can improve the efficiency of operation.
In summary, the relationship between processes and threads has the following four characteristics.
- If any thread in the process fails to execute, the whole process will crash.
- Data in the process is shared between threads.
- When a process is shut down, the operating system reclaims the memory used by the process.
- Content between processes is isolated from each other.
Only one page has been opened. Why are there four processes?
Because opening a page requires at least one network process, one browser process, one GPU process and one rendering process, a total of 4; if the opened page has a plug-in running, another plug-in process needs to be added.
However, there are two sides to everything. Although the multi process model improves the stability, fluency and security of the browser, it also inevitably brings some problems:
- More complex architecture。 The problems of high coupling and poor scalability among browser modules will make the current architecture difficult to adapt to the new requirements.
- The relationship between IP, UDP and TCP
- Restful API architecture style for the front end
- Tips: reuse your code with mixins of vue.js
Reference: geek time “browser working principle and practice”, 01 | chrome architecture: only one page has been opened, why are there four processes? https://time.geekbang.org/col…