Introducing concurrency
As we explored in the introduction of Chapter 1, An Introduction to Rust from a Python Perspective, Moore's law is now failing, and therefore we have to consider other ways in which we can speed up our processing. This is where concurrency comes in. Concurrency is essentially running multiple computations at the same time. Concurrency is everywhere, and to give the concept full justice, we would have to write a whole book on it.
However, for the scope of this book, understanding the basics of concurrency (and when to use it) can add an extra tool to our belt that enables us to speed up computations. Furthermore, threads and processes are how we can break up our program into computations that run at the same time. To start our concurrency tour, we will cover threads.
Threads
Threads are the smallest unit of computation that we can process and manage independently. Threads are used to break a program into computational parts that can be run at...