Skip to content

Instantly share code, notes, and snippets.

@alexniver
Last active November 24, 2015 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexniver/18d3d93d61859652e688 to your computer and use it in GitHub Desktop.
Save alexniver/18d3d93d61859652e688 to your computer and use it in GitHub Desktop.
根据文章标题, concurrency-is-not-parallelism
看了下视频和PPT, 也看了下例子. 写下大概理解.
concurrency, 是指针对某种场景, 构建一个模型,这个模型可以是串行的, 也可以是并行的,这时的主要设计目标在于设计的模型必须安全,简洁,高效;parallelism则是运行多个这个模型.
拿PPT中烧书的例子, 这里的concurrency是指如何处理烧书这个问题(how to deal this problem), 可以一个人搬书去烧, 也可以两个人搬书去烧. 两个人的情况, 如果两人同时工作, 这时即是concurrency, 也是parall的, 如果两个人串行工作, 则这时便是concurrency但非parallel的.
之后例子中又给出了更好的concurrency模型, 4个人过来 , 1负责往车里放书, 2负责推车去火堆, 3负责把书扔炉子里,4负责把空车运回来. 这时这个问题就构建出了一个比较好的concurrency模型(运行时间为4个人中最慢的那个人的时间),同时这个模型也是parall的.
在构建出不错的模型之后, 便可以并行运行这个模型来进行烧书, 如: 组4个小队, 每队4人根据这个模型运作, 这时, 这4个小队之间就是parallel的.
这时再理解下面这5句话就容易多了.
Concurrency is powerful.
Concurrency is not parallelism.
Concurrency enables parallelism.
Concurrency makes parallelism (and scaling and everything else) easy.
Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment