What is the difference between concurrency and parallelism?

前端 未结 30 2659
清歌不尽
清歌不尽 2020-11-22 00:21

What is the difference between concurrency and parallelism?

Examples are appreciated.

30条回答
  •  温柔的废话
    2020-11-22 00:59

    I really like Paul Butcher's answer to this question (he's the writer of Seven Concurrency Models in Seven Weeks):

    Although they’re often confused, parallelism and concurrency are different things. Concurrency is an aspect of the problem domain—your code needs to handle multiple simultaneous (or near simultaneous) events. Parallelism, by contrast, is an aspect of the solution domain—you want to make your program run faster by processing different portions of the problem in parallel. Some approaches are applicable to concurrency, some to parallelism, and some to both. Understand which you’re faced with and choose the right tool for the job.

提交回复
热议问题