IT lexicon › Programming › Shared mutable state

Shared mutable state

Programming På svenska → Updated: 2026-11-16

The situation where multiple threads can read and modify the same data unsafely, creating race conditions and data corruption.

Shared mutable state is the root of most concurrency bugs. Two threads can overwrite each other, lose updates, or see torn intermediate states. Solutions include protecting access with mutexes, using atomic operations, or redesigning to eliminate sharing (immutable objects, actor model, thread-local data). Many modern languages push back against this pattern: Rust forbids it at compile time without unsafe; Go encourages channels over shared memory; Clojure offers persistent data structures. The shift reflects the real cost: shared mutable state is the hardest concurrency problem to reason about.

This is why Rust's borrow checker exists—to make shared mutable state require explicit unsafe blocks.

← Back to the lexicon