并行parallel和并发concurrent的区别
http://stackoverflow.com/questions/1050222/concurrency-vs-parallelism-what-is-the-difference
Concurrency is when two or more tasks can start, run, and complete in overlapping time periods. It doesn't necessarily mean they'll ever both be running at the same instant. Eg. multitasking on a single-core machine.
Parallelism is when tasks literally run at the same time, eg. on a multicore processor.
Quoting Sun's Multithreaded Programming Guide:
-
Concurrency: A condition that exists when at least two threads are making progress. A more generalized form of parallelism that can include time-slicing as a form of virtual parallelism.
-
Parallelism: A condition that arises when at least two threads are executing simultaneously.
参考:
http://www.cnblogs.com/ty408/p/5801148.html
http://www.cnblogs.com/zlcxbb/p/5754346.html
Concurrency vs Parallelism
https://www.codeproject.com/Articles/1267757/Concurrency-vs-Parallelism
This article will explain the difference between concurrency and parallelism. Concurrency vs parallelism has been a debated topic for a long time.
Actual Parallelism Vs Feel of Parallelism
Technical vocabulary in IT industry is sometimes very confusing and “Concurrency” and “Parallelism” are some of them. Many developers think “Concurrency and parallelism means executing at the same time” which is right 50%, but with one big difference:
- Concurrency gives you a feel of parallelism and parallelism as the name implies is actual parallelism.
Feel of parallelism means you execute multiple tasks on the same core and the core switches context between tasks and serves them. You can also term this has time slicing / overlapping time period because your single core is just dedicating some time to one task and then some time to other.
Actual parallelism means you execute multiple tasks on multiple cores parallely.
Note: “Concurrency is a broader term and Parallelism is a subset of it”.
Mapping to the real world, the left image depicts parallelism the right image depicts concurrency.
Why a Feel of Parallelism and Why Not Actual?
In order to achieve actual parallelism, we need dedicated cores, separate memory and so on. Let’s say we want to show a progress bar for some task completed. Now we really do not want to have separate cores allocated to display the progress. |
We do not want PERFORMANCE here, we want that physiologically the end user feels both tasks are happening simultaneously.
We want to just beat the human eye capability of 100 FPS and give an illusion of parallelism without stressing our computer resources. But let’s say we want to process big Excel files with a million records, then yes we would love to have actual parallelism to achieve performance.
Is multi-thread belongs to concurrent or parallel?
Concurrency and parallelism are related but different concepts in computer science.
Concurrency means multiple tasks can run in overlapping time periods, but not necessarily simultaneously. In a concurrent system, a single processor can be shared among multiple tasks using techniques such as context switching or time-slicing. This is often used to improve the efficiency and responsiveness of a system.
Parallelism, on the other hand, means multiple tasks are actually executing simultaneously, typically on different processors or cores. Parallelism is used to achieve faster processing times by dividing a single large task into smaller, parallelizable subtasks that can be processed simultaneously.
Multithreading involves concurrency as it allows multiple threads (smaller subtasks of a program) to run simultaneously on a single processor through time-slicing. However, it can also involve parallelism if the program is running on a machine with multiple processors or cores, allowing the threads to run truly in parallel.
Therefore, multithreading can belong to both concurrent and parallel programming paradigms.
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2015-08-25 IIS中的Application.CommonAppDataPath
2014-08-25 C#中的编译开关
2014-08-25 VS中自动选择x86或x64的dll