← Rust Programming learning pathRust Programming · Module 9 of 10
Concurrency and async
Write fearless concurrent code.
📖 Key ideas
- std::thread::spawn starts threads.
- Channels (mpsc) pass messages between threads.
- Arc<Mutex<T>> shares mutable data safely.
- Send and Sync traits ensure thread safety at compile time.
- Async Rust with async/await and the Tokio runtime.
💡 Real-life example: Rust concurrency is a bank with strict locker rules: no two people can open the same locker at once.
thread::spawnStarts an OS thread
ArcAtomic reference-counted pointer
MutexMutual exclusion lock
TokioAsync runtime