Start with the idea
Send means a value can be moved to another thread; Sync means &T can be shared with one. Both are inferred from a type's fields, so you rarely write them — but they are why Rc is rejected at compile time while Arc is accepted, and why a whole class of race is a type error.
Send and Sync are marker traits describing safe movement and sharing across threads. A Send value may transfer ownership to another thread. A Sync type may be accessed through shared references from multiple threads; equivalently, &T can be Send when T is Sync. These properties are usually derived automatically from fields, so the type composition communicates the safety constraint.
Rc<T> changes a non-atomic reference count, so it is unsuitable for sharing between threads. Arc<T> uses an atomic count, but that does not make arbitrary inner mutation safe.
Keep learning, for free
The rest of this lesson is waiting for you.
Create a free account to read the complete explanation, see the infographic, explore the code, and try the exercises. All 742 lessons and algorithm steps are included.
No payment details. Your account opens the complete Academy.