当前位置:网站首页>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
边栏推荐
- Win11如何更改默认下载路径?Win11更改默认下载路径的方法
- Maxwell 一款简单易上手的实时抓取Mysql数据的软件
- MySQL database --- Addition, deletion, modification and query of MySQL tables (advanced)
- 试写C语言三子棋
- 【无标题】多集嵌套集合使不再有MultipleBagFetchException
- [Private Series] All kinds of strange problems encountered in daily PHP
- 明解C语言第七章习题
- 用jOOQ 3.17投射类型安全的嵌套表记录
- 在jOOQ中获取数据的多种不同方式
- 多线程的互斥锁应用RAII机制
猜你喜欢
Cesium loads offline maps and offline terrain
Snowflake vs. Redshift的2022战报:两个数据平台谁更适合你?
The JDBC programming of the MySQL database
How to build FTP server under win2003
MySQL函数(经典收藏)
[Node implements data encryption]
网络层协议------IP协议
LeetCode 0952.按公因数计算最大组件大小:建图 / 并查集
These services can't ali interview?Then don't go to, the basic notification, etc
PHP低代码开发平台 V5.0.7新版发布
随机推荐
MySQL函数(经典收藏)
After MySQL grouping, take the largest piece of data [optimal solution]
Database indexes: indexes are not a panacea
推荐系统-排序层-模型(一):Embedding + MLP(多层感知机)模型【Deep Crossing模型:经典的Embedding+MLP模型结构】
These services can't ali interview?Then don't go to, the basic notification, etc
ELK日志分析系统
055 c# print
MySQL数据库————视图和索引
“数字化重构系统,搞定 CEO 是第一步”
湖仓一体电商项目(四):项目数据种类与采集
MySql密码
MySQL数据库之JDBC编程
MySQL六脉神剑,SQL通关大总结
牛客网——华为题库(100~108)
数据库索引:索引并不是万能药
After watching "Second Uncle", I was even more internalized
MySQL six-pulse sword, SQL customs clearance summary
[Node implements data encryption]
MySQL mass production of data
移动web开发01