Often, we'd like our programs to do several things at the same time:
- The user interface of a program continues working normally even though our program connects to the network
- A game updates the state of thousands of units at the same time, while playing a soundtrack in the background
- A scientific program splits computation in order to take full advantage of all the cores in the machine
- A web server handles more than one request at a time in order to maximize throughput
Rust has a safe form of concurrency, backed by the memory model system described in the previous chapter. In this chapter, we will go through how multithreading, sharing state, and message passing work in Rust.
The topics covered in this chapter are as follows: ...