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

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
主站蜘蛛池模板: 玛纳斯县| 桓仁| 古浪县| 大化| 安多县| 陇川县| 淄博市| 古田县| 阿拉尔市| 樟树市| 泽库县| 林甸县| 涡阳县| 清新县| 土默特右旗| 盐池县| 安平县| 烟台市| 萨嘎县| 门源| 萝北县| 肇州县| 莱阳市| 蒙城县| 金溪县| 铁力市| 通州区| 南昌市| 嘉荫县| 乾安县| 珲春市| 辽宁省| 鄂伦春自治旗| 青冈县| 中阳县| 临潭县| 乌兰县| 重庆市| 延津县| 玛沁县| 武城县|