-
Book Overview & Buying
-
Table Of Contents
Rust for C++ Developers
By :
Multithreaded code can run into several different problems that single-threaded code doesn't have to worry about. As a result, it has gained a reputation for being difficult and error-prone. Still, many of these problems are reduced and even eliminated in safe Rust. In this section, we'll examine a few of these problems and learn how Rust deals with them.
One of the most common problems with multithreaded code is known as a race condition. The term evokes the imagery of vehicles racing against one another. The track in this analogy is a section of our code, while the cars are the different threads competing against one another to finish executing it. However, in programming, we're less concerned with the winner of the race than with the order in which each car passes each point on the track.
When we talk about race conditions in code, we're talking about a situation where the code has malfunctioned...