209. Explaining concurrency vs. parallelism
Before tackling the main topic of this chapter, structured concurrency, let’s forget about structure, and let’s keep only concurrency. Next, let’s put concurrency against parallelism, since these two notions are often a source of confusion.
Both of them, concurrency and parallelism, use tasks as the main unit of work. However, the way that they handle these tasks makes them very different.
In the case of parallelism, a task is split into subtasks across multiple CPU cores. These subtasks are computed in parallel, and each of them represents a partial solution for the given task. By joining these partial solutions, we obtain the solution. Ideally, solving a task in parallel should result in less wall-clock time than in the case of solving the same task sequentially. In a nutshell, in parallelism, at least two threads run at the same time, which means that parallelism can solve a single task faster.
In the...