Stackoverflow 精彩答案整理…
本人英语水平渣渣,翻译的主要目的自己整理加深理解。如果不幸误导您,请见谅。如果您好心提醒我,可以直接底下留言。
Concurrency is when two 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:
引自 <<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.
并行:在这样的条件下出现:至少两个线程正在同时执行。
另一个比较形象的解释:
Rob usually talks about Go and usually addresses the question of Concurrency vs Parallelism in a visual and intuitive explanation! Here is a short summary:
Task: Let’s burn a pile of obsolete language manuals! One at a time!
任务:烧掉一堆古老的语言参考手册。顺序执行:
Concurrency: There are many concurrently decompositions of the task! One example:
并发:任务分解,并发执行:
Parallelism: The previous configuration occurs in parallel if there are at least 2 gophers working at the same time or not.
至少要两只土拔鼠同时工作才能算的得上是并行。
Confusion exists because dictionary meanings of both these words are almost the same:
因为字典中把并发和并行解释的意思基本是相同的,所以有疑惑很正常。
Concurrent: existing, happening, or done at the same time(dictionary.com)
Parallel: very similar and often happening at the same time(merriam webster).
Yet the way they are used in computer science and programming are quite different. Here is my interpretation:
但是它们在CS中使用时有很大区别。这里是我的解释:
Concurrency: Interruptability
并发:可中断。
Parallelism: Independentability
并行:无相互依赖关系。
篇幅有限,更多解释可以看原文,链接在最上面。