Wednesday, August 31, 2016

An easy explanation of the difference between concurrency and parallelism

Sometimes it takes a long time to acquire understanding of something and finally I've understood the difference between parallelism and concurrency.

Suppose you have 3 huge bags you have to move from your house to your friend's house. You want to save money thus you don't take a taxi and decide to go on foot caring the bags only by yourself. They're so huge, however, that you can only carry one bag at a time. The city you're in is safe enough so you can leave them on the street and no one will steal them.

Concurrency: you carry one bag 10 meters, quickly return to the place where you left your 2nd and 3rd bags, grad the 2nd one and carry it 10 meters, then again quickly come back, grab the 3rd one and carry the same 10 meters. Then you take the 1st bag again, carry it for 10 meters, come back and grab the 2nd one, carry it and take the 3rd one. And so on and so forth until you bring all of them to your friend's house.

Parallelism: you ask two your brothers to help you out and you three take those three bags at the same time, one bag for each person, and bring them to your friend's house.

Asynchronism: it's not directly related to these 2.

No comments :

Post a Comment