What Is an Atomic Variable
You Can Think of These Are Wrapper of Primitive Types Boolean, Integer and Long, with the Difference: They Are Designed to Be Safely Used in Multi-Threaded...
You can think of these are wrapper of primitive types boolean, integer and long, with the difference: they are designed to be safely used in multi-threaded context. They are called atomic variables because they provide some operations that cannot be interfered by multiple threads.
What is an atomic variable in C?
Atomics as part of the C language are an optional feature that is available since C11. Their purpose is to ensure race-free access to variables that are shared between different threads. Without atomic qualification, the state of a shared variable would be undefined if two threads access it concurrently.
How do atomic variables work?
Declaring an atomic variable guarantees that operations made on the variable occur in an atomic fashion, i.e., that all of the substeps of the operation are completed within the thread they are executed and are not interrupted by other threads.