ABSTRACT

This chapter discusses using threads to run code simultaneously, using message passing to transfer data between threads, shared-state concurrency, and extensible concurrency with the Sync and Send traits. Initially, the Rust team believed that ensuring memory safety and preventing concurrency concerns were two distinct challenges that needed to be addressed using different approaches. Threads are implemented differently in different computer languages. Green threads are threads given by programming languages, and languages that employ them will execute them in the context of a different number of operating system threads. Rust's type system and ownership rules are extremely helpful in getting this management right. Consider mutexes, which are one of the most commonly used concurrency primitives for shared memory.