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

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.

主站蜘蛛池模板: 巫溪县| 仁寿县| 色达县| 达拉特旗| 化州市| 广河县| 丹棱县| 棋牌| 鄯善县| 托克逊县| 安岳县| 青铜峡市| 遂宁市| 禄劝| 桃园市| 梁山县| 泌阳县| 五寨县| 怀仁县| 酒泉市| 江门市| 苗栗县| 洪湖市| 伽师县| 临西县| 绍兴市| 横峰县| 肇庆市| 凤冈县| 哈尔滨市| 乌兰浩特市| 大关县| 新竹市| 类乌齐县| 仙游县| 扶绥县| 大悟县| 蕲春县| 左云县| 贡嘎县| 宜宾市|