What atomicity means
In the context of software execution, an operation is atomic when it is single and indivisible. When talking about shared state, we are often talking about reading or writing to a single variable from many threads.
A challenge is raised because modifying the state of a variable is usually not atomic, since it usually consists of multiple steps like reading, modifying, and storing the updated value. During the execution of concurrent applications it's possible that a block of code that modifies a shared state does it by overlapping changes from other threads—for example, one thread can read the current value while another is modifying it, but before it being written. This situation will mean that one or more modifications ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access