Concurrency and parallelism are two related concepts which deal with executing tasks "simultaneously".
- 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.
These two definitions are too formal to be understood easily. On the Internet, there is one image which demonstrates the difference between these two in an easy way:

Much easier to understand,right? For concurrency, tasks can start, run and complete in overlapping the time periods, but they may not run at the same instant, when one task in a queue is running, another task in the other queue will wait. While for parallelism, two tasks can run at the same instant. Concurrency has states which means they know status of other tasks execution, while parallelism is stateless.
With concurrency, we want to improve the responsiveness of the application, with parallelism, we want to improve the utilization efficiency of processors, as the computing speed of a single CPU is driving to its limit, so we try to integrate more processors on a single CPU to distribute tasks among different processors.
本文深入解析并发与并行的概念,解释它们如何在提高应用程序响应性和处理器利用率方面发挥作用。通过直观的比喻,清晰阐述并发与并行的不同特性,以及在不同场景下的实际应用。
998

被折叠的 条评论
为什么被折叠?



