IT lexicon › Programming › Software transactional memory

Software transactional memory

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

A programming construct that lets multiple threads update memory atomically without explicit locks — reads and writes are buffered, and if a conflict arises, the sequence replays.

STM operates on optimistic locking: a thread assumes conflicts are rare and begins work, recording all reads and writes in a local transaction log. At commit time, the log is validated and compared against other threads' changes. If they conflict, the code replays (like an ACID rollback at the source level).

The advantage is avoiding hand-tuned lock granularity and deadlock risks. The downside: transaction overhead and potential starvation if two threads constantly collide. STM was explored heavily in the 2010s as an alternative to fine-grained locking but never became mainstream; Java and C++ stuck with careful lock tuning or lock-free data structures instead.

← Back to the lexicon