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

A quick metaphor

Concurrency is a quite difficult concept to fully grasp immediately, so let's consider a quick metaphor, in order to make concurrency and its differences from parallelism easier to understand.

Although some neuroscientists might disagree, let's briefly assume that different parts of the human brain are responsible for performing separate, exclusive body part actions and activities. For example, the left hemisphere of the brain controls the right side of the body, and hence, the right hand (and vice versa); or, one part of the brain might be responsible for writing, while another solely processes speaking.

Now, let's consider the first example, specifically. If you want to move your left hand, the right side of your brain (and only the right side) has to process that command to move, which means that the left side of your brain is free to process other information. So, it is possible to move and use the left and right hands at the same time, in order to do different things. Similarly, it is possible to be writing and talking at the same time.

That is parallelism: where different processes don't interact with, and are independent of, each other. Remember that concurrency is not quite like parallelism. Even though there are instances where processes are executed together, concurrency also involves sharing the same resources. If parallelism is similar to using your left and right hands for independent tasks at the same time, concurrency can be associated with juggling, where the two hands perform different tasks simultaneously, but they also interact with the same object (in this case, the juggling balls), and some form of coordination between the two hands is therefore required.

主站蜘蛛池模板: 屏东市| 麻栗坡县| 阿拉善右旗| 色达县| 青海省| 汉寿县| 锡林郭勒盟| 色达县| 巴彦县| 宝兴县| 吕梁市| 奉新县| 凯里市| 廊坊市| 定远县| 固原市| 晋州市| 吉安县| 桂平市| 克拉玛依市| 集贤县| 济南市| 东源县| 盐津县| 黔西县| 沾益县| 大埔区| 中江县| 三门峡市| 嘉定区| 孝义市| 乌兰县| 贵港市| 阜宁县| 巴林左旗| 巴林左旗| 邯郸市| 壤塘县| 怀远县| 凤翔县| 莱芜市|