官术网_书友最值得收藏!

Concurrent versus parallel

At this point, if you have had some experience in parallel programming, you might be wondering whether concurrency is any different from parallelism. The key difference between concurrent and parallel programming is that, while in parallel programs there are a number of processing flows (mainly CPUs and cores) working independently all at once, there might be different processing flows (mostly threads) accessing and using a shared resource at the same time in concurrent programs.

Since this shared resource can be read and overwritten by any of the different processing flows, some form of coordination is required at times, when the tasks that need to be executed are not entirely independent from one another. In other words, it is important for some tasks to be executed after the others, to ensure that the programs will produce the correct results.

Difference between concurrency and parallelism

The preceding figure illustrates the difference between concurrency and parallelism: while in the upper section, parallel activities (in this case, cars) that do not interact with each other can run at the same time, in the lower section, some tasks have to wait for others to finish before they can be executed.

We will look at more examples of these distinctions later on.

主站蜘蛛池模板: 通河县| 宜宾市| 金乡县| 晋州市| 云安县| 车致| 汶上县| 安康市| 铁力市| 石渠县| 前郭尔| 江门市| 盐津县| 搜索| 杨浦区| 崇明县| 克东县| 化德县| 娄烦县| 朝阳区| 湖南省| 科尔| 铁岭县| 买车| 潜山县| 乡宁县| 阜阳市| 乌拉特中旗| 大庆市| 灵丘县| 禄丰县| 炎陵县| 枞阳县| 关岭| 镇巴县| 若羌县| 乐山市| 西峡县| 鹤山市| 曲沃县| 陆川县|