Concurrency vs Parallelism
Concurrency: dealing with multiple tasks at once
Example: trying to eat while having a conversation.
It might be possible to do so, but you can't talk while chewing your food because you only have 1 mouth.
Your mouth switch context so often between chewing and talking, you might think that you are doing both in parallel at the same time (but actually, no).
In the context of software engineering, having 1 mouth in the example is the same as having only 1 thread.
Doing tasks asynchronously (with a single thread) will help us to achieve concurrency.
Parallelism: doing multiple tasks at once
Example: eating while having a conversation, but you have 2 mouths.
You have 2 mouths so you can eat and talk at the same time.
If eating while having a conversation will make the it finish at 10 minutes, having 2 mouths will help you to finish it in 5 minutes.
In the context of software engineering, having 2 mouths in the example is the same as having 2 threads with different cpu cores handling them.
Last updated