- Mastering Clojure
- Akhil Wali
- 238字
- 2021-07-09 20:18:03
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
推薦閱讀
- Microsoft Dynamics 365 Extensions Cookbook
- arc42 by Example
- Three.js開(kāi)發(fā)指南:基于WebGL和HTML5在網(wǎng)頁(yè)上渲染3D圖形和動(dòng)畫(huà)(原書(shū)第3版)
- BeagleBone Media Center
- ASP.NET動(dòng)態(tài)網(wǎng)頁(yè)設(shè)計(jì)教程(第三版)
- 區(qū)塊鏈:以太坊DApp開(kāi)發(fā)實(shí)戰(zhàn)
- Unity UI Cookbook
- 移動(dòng)互聯(lián)網(wǎng)軟件開(kāi)發(fā)實(shí)驗(yàn)指導(dǎo)
- Processing創(chuàng)意編程指南
- Python Interviews
- Modular Programming with JavaScript
- Java自然語(yǔ)言處理(原書(shū)第2版)
- C Primer Plus(第6版)中文版【最新修訂版】
- SaaS攻略:入門、實(shí)戰(zhàn)與進(jìn)階
- HTML5 and CSS3:Building Responsive Websites