当前位置:网站首页>What are the relationships and differences between threads and processes
What are the relationships and differences between threads and processes
2022-04-23 18:03:00 【OceanKeeper1215】
Thread definition
Thread is the basic execution unit of a process , All tasks of a process are executed in threads
The process wants to perform the task , There must be threads , The process must have at least one thread
The program will start a thread by default , This thread is called the main thread or UI Threads
Process definition
A process is an application running in the system
Each process is independent , Each process runs in its own dedicated and protected memory
The difference between a process and a thread
address space : Threads of the same process share the address space of this process , And there is an independent address space between processes .
Resource ownership : Threads in the same process share the resources of the process ( Such as memory 、I/O、cpu etc. ), But the resources between processes are independent .
After a process crashes , No impact on other processes in protected mode , But when a thread crashes, the whole process dies . So multiprocessing is more robust than multithreading .
Process switching , It consumes a lot of resources , Efficient . So when it comes to frequent switching , It's better to use threads than processes . Also, if concurrent operations of some variables are required to be performed at the same time and shared at the same time , Only threads, not processes
Execution process : Each independent process has an entry for the program to run 、 Sequential execution sequence and program entry . But the thread cannot execute independently , Must exist in the application , Multiple thread execution control provided by the application .
Threads are the basic unit of processor scheduling , But the process is not .
advantage
It can improve the efficiency of program execution
It can improve the utilization rate of resources (CPU, Memory )
When the task on the thread is finished , The thread will automatically destroy
shortcoming
Starting a thread requires a certain amount of memory space ( By default , Every thread takes up 512 KB)
If you start a lot of threads , It takes up a lot of memory space , Reduce the performance of the program
More threads ,CPU The higher the overhead on the calling thread
Programming is more complicated , For example, communication between threads 、 Multithreaded data sharing
版权声明
本文为[OceanKeeper1215]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230545104956.html
边栏推荐
- 纳米技术+AI赋能蛋白质组学|珞米生命科技完成近千万美元融资
- [UDS unified diagnostic service] v. diagnostic application example: Flash bootloader
- 2022江西储能技术展会,中国电池展,动力电池展,燃料电池展
- cv_ Solution of mismatch between bridge and opencv
- Crawler for querying nicknames and avatars based on qqwebapi
- Submit local warehouse and synchronize code cloud warehouse
- Vite configure proxy proxy to solve cross domain
- Add animation to the picture under V-for timing
- Installation du docker redis
- Classification of cifar100 data set based on convolutional neural network
猜你喜欢

Jenkspy package installation

Auto. JS custom dialog box

Qtablewidget usage explanation

Go对文件操作
![[UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)](/img/ae/cbfc01fbcc816915b1794a9d70247a.png)
[UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)

2022 judgment questions and answers for operation of refrigeration and air conditioning equipment

MySQL auto start settings start with systemctl start mysqld

re正则表达式

Theory and practice of laser slam in dark blue College - Chapter 2 (odometer calibration)

Docker 安装 Redis
随机推荐
MySQL_01_简单数据检索
Use of list - addition, deletion, modification and query
Excel opens large CSV format data
Crawl the product data of Xiaomi Youpin app
Jenkspy package installation
Selenium + webdriver + chrome realize Baidu to search for pictures
Flash operates on multiple databases
cartographer_ There is no problem compiling node, but running the bug that hangs directly
C#字节数组(byte[])和字符串相互转换
Go language JSON package usage
The method of changing a value in the array and a value in the object of wechat applet
Halo 开源项目学习(二):实体类与数据表
Selenium + phantom JS crack sliding verification 2
Submit local warehouse and synchronize code cloud warehouse
解决允许在postman中写入注释请求接口方法
2022 tea artist (primary) examination simulated 100 questions and simulated examination
读取excel,int 数字时间转时间
ArcGIS license error -15 solution
.104History
C#的随机数生成