What’s the difference between parallelism and concurrency

Example 1

You’re in the middle of a meal when the phone comes and you don’t answer it until after you’ve finished, which means you don’t support concurrency or parallelism. You’re in the middle of a meal when the call comes, you stop to take the call, and then continue eating, which means you support concurrency (not necessarily simultaneous). Do you eat for dinner to a half, the phone call came, you make a phone call while have a meal, it shows you support parallel [] (from: blog.csdn.net/u010214802/…)

Example 2: Multitasking (that is, switching quickly) on one CPU. Parallelism is the simultaneous processing of multiple tasks on multiple cpus (like hadoop distributed clusters)

describe

Concurrency: the ability of an application to perform different tasks alternately. Concurrency is similar to multithreading, which does not execute multiple tasks at the same time, but rather switches them quickly. If you have two threads running, you’re constantly switching between the two tasks at a speed that’s almost impossible to notice, and you’ve achieved “simultaneous execution.” It’s not “simultaneous,” it’s just that the computer is moving too fast for us to notice. For example, if you take a bite of rice, take a bite of water, take another bite of rice, take another bite of water, at normal speed, you can see it completely, but when you perform this process at n times the speed… Imagine drinking and eating all the time. Parallelism: The ability of an application to perform different tasks at the same time. For example, eating while listening to music can be done at the same time.

conclusion

The key to concurrency is that you have the ability to handle multiple tasks, but not all at once. The key to parallelism is that you’re working on multiple tasks at once. The key point is whether they are the same. The difference between the two: concurrency is executed alternately, parallelism is executed simultaneously.