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

Chapter 2. Orchestrating Concurrency and Parallelism

Let's now examine how concurrent and parallel programming are supported in Clojure. The term concurrent programming refers to managing more than one task at the same time. Parallel programming or parallelism, on the other hand, deals with executing multiple tasks at the same time. The distinction between these two terms is that concurrency is about how we structure and synchronize multiple tasks, and parallelism is more about running multiple tasks in parallel over multiple cores. The main advantages of using concurrency and parallelism can be elaborated as follows:

  • Concurrent programs can perform multiple tasks simultaneously. For example, a desktop application can have a single task for handling user interaction and another task for handling I/O and network communication. A single processor can be shared among several tasks. Processor utilization is thus more effective in concurrent programs.
  • Parallel programs take advantage of having multiple processor cores. This means that such programs can be made to run faster by executing them on a system with more processor cores. Also, tasks that are computationally expensive can be parallelized to complete in a lesser amount of time.

In this chapter, we will:

  • Explore how we can create and synchronize tasks that run concurrently
  • See how to deal with a shared state between concurrent tasks
  • Examine how computations can be parallelized and how we can control the amount of parallelism used to perform these computations
主站蜘蛛池模板: 达日县| 滦平县| 裕民县| 阳城县| 瓮安县| 泰安市| 怀柔区| 眉山市| 曲沃县| 德清县| 安溪县| 郯城县| 沙雅县| 师宗县| 清水河县| 达孜县| 逊克县| 武强县| 文成县| 郯城县| 莆田市| 瓮安县| 林周县| 华坪县| 香格里拉县| 抚松县| 如皋市| 黄冈市| 通许县| 黄山市| 长沙市| 常州市| 伊春市| 天镇县| 株洲市| 左权县| 邛崃市| 黄石市| 缙云县| 苏尼特右旗| 泽州县|