Arc
Arc is Rust’s atomically reference-counted smart pointer for shared ownership of a value across threads.
Code Like a Pro in Rust
Arc is a Rust thread-safe reference-counted smart pointer for shared ownership of a value across threads.
- How it is used
- Enables shared ownership across threads and appears in a parallel-test counter.
- How deep it goes
- Explains reference-count changes and atomic cost, then works through global initialization; stops short of implementing Arc.
- Examples
- Uses a parallel-test counter, compiler errors, `Arc::clone`, and `lazy_static!` to expose an initialization pitfall.
- What you can do after
- Apply it via Rust's `Arc` when ownership crosses threads, choosing synchronization or clone-on-write separately.
Learn Rust in a Month of Lunches
Arc is Rust's atomically reference-counted smart pointer for sharing ownership of a value safely across threads.
- How it is used
- Shares ownership of values across threads while coordinating access through thread-safe types.
- How deep it goes
- Defines atomic operations and demonstrates cloning, locking, spawning, joining, and repeated shared-counter updates.
- Examples
- Uses Arc<Mutex<i32>> counters, two-thread increments, ten-thread loops, and helper functions that construct and clone Arcs.
- What you can do after
- Build shared counters with Arc, Mutex, spawned threads, cloned owners, and joined handles.
Related concepts
- Rcalternative to · Rc is Rust’s single-threaded reference-counted smart pointer for shared ownership of a value.
- smart pointerkind of · A smart pointer is a pointer-like object that manages or mediates access to a referenced resource, often providing ownership, lifetime, or safety behavior.
- atomicityuses · Atomicity is the property that an operation or group of operations takes effect as an indivisible, all-or-nothing unit, without observable partial effects.
- reference-counted pointerkind of · A reference-counted pointer is a pointer-like value whose referenced allocation is reclaimed when its tracked reference count reaches zero.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

