当前位置:网站首页>Difference Between Concurrency and Parallelism
Difference Between Concurrency and Parallelism
2022-07-30 20:02:00 【a ray of sunshine】
When you learn multithreading, you will encounter a term: concurrency.This is a vocabulary in the operating system. It is necessary to understand the difference between concurrency and parallelism. I have collected several expressions from the Internet to help understand.
One:
Concurrency means that a processor handles multiple tasks at the same time.
Parallelism refers to the simultaneous processing of multiple different tasks by multiple processors or multi-core processors.
Concurrency is logically simultaneous (simultaneous), while parallelism is physically simultaneous.
Let's take an analogy: Concurrency means that one person eats three steamed buns at the same time, while parallelism means that three people eat three steamed buns at the same time.
2:
Parallel (parallel): refers to the simultaneous execution of multiple instructions on multiple processors at the same time.It's as if two people are digging a hole with a shovel each, and after an hour, each person will have a big hole.So no matter from a micro or macro point of view, the two are executed together.

Write image description here
Concurrency: It means that only one instruction can be executed at the same time, but multiple process instructions are rapidly executed in turn, so that it has the effect of multiple processes executing at the same time in the macro, but not at the same time in the micro, just divide the time into several segments, so that multiple processes can be executed alternately quickly.It's like two people using the same shovel and taking turns digging a hole. After an hour, they each dig a smaller hole. If they want to dig two larger holes, it will definitely take two hours.
Write a picture description here

Parallelism exists in multiprocessor systems, and concurrency can exist in both uniprocessor and multiprocessor systems. Concurrency can exist in uniprocessor systems because concurrency is an illusion of parallelism. Parallelism requires programs to be able to simultaneouslyMultiple operations are performed, while concurrency simply requires the program to pretend to perform multiple operations simultaneously (one operation per small time slice, multiple operations switching execution quickly).
Three:
When there are multiple threads in operation, if the system has only one CPU, it is impossible to perform more than one thread at the same time. It can only divide the CPU running time into several time periods.The time period is then allocated to each thread for execution. When the thread code of a period of time is running, other threads are in a suspended state. This method is called Concurrent.
When the system has more than one CPU, the operations of threads may be non-concurrent. When one CPU executes one thread, the other CPU can execute another thread. The two threads do not preempt each other's CPU resources and can be performed simultaneously.We call this method Parallel.
Write image description here
边栏推荐
- MySql密码
- M3SDA: Moment matching for multi-source domain adaptation
- Linux下安装Mysql5.7,超详细完整教程,以及云mysql连接
- MySQL slow query optimization
- MySQL mass production of data
- 明解C语言第六章习题
- Start foreground Activity
- ImportError:attempted relative import with no known parent package
- 基于人脸的常见表情识别(2)——数据获取与整理
- Database indexes: indexes are not a panacea
猜你喜欢

Centos7 install mysql8
![Recommended system: cold start problem [user cold start, item cold start, system cold start]](/img/e1/c3f8c89616d63cd3af84e715e783f9.png)
Recommended system: cold start problem [user cold start, item cold start, system cold start]

Face-based Common Expression Recognition (2) - Data Acquisition and Arrangement

Ordinary int main(){} does not write return 0; what will happen?

Cesium loads offline maps and offline terrain

coming!Dongfang Selection brings goods to the live broadcast of Longjiang agricultural products

Encapsulates a console file selector based on inquirer

倾斜文档扫描与字符识别(opencv,坐标变换分析)

MySQL database master-slave configuration
![After MySQL grouping, take the largest piece of data [optimal solution]](/img/ff/b8218cb010b8be7d0564e45d4efa70.png)
After MySQL grouping, take the largest piece of data [optimal solution]
随机推荐
Win11如何更改默认下载路径?Win11更改默认下载路径的方法
MySQL eight-part text recitation version
Encapsulates a console file selector based on inquirer
MySQL数据库主从配置
Interviewer Ali: Describe to me the phenomenon of cache breakdown, and talk about your solution?
MySQL sub-database sub-table
阿里面试这些微服务还不会?那还是别去了,基本等通知
055 c# print
jOOQ是如何设计事务API(详细指南)
推荐系统:AB测试(AB Test)
ERROR 1045 (28000) Access denied for user ‘root‘@‘localhost‘解决方法
MySQL database --- Addition, deletion, modification and query of MySQL tables (advanced)
PHP低代码开发平台 V5.0.7新版发布
ERROR 1045 (28000) Access denied for user 'root'@'localhost'Solution
MySQL database - views and indexes
在jOOQ中获取数据的多种不同方式
Perfectly Clear QuickDesk & QuickServer图像校正优化工具
ImportError:attempted relative import with no known parent package
18.客户端会话技术Cookie
MindSpore:ImageFolderDataset数据读取问题