ABA Problem In multithreaded computing, the ABA problem occurs during synchronisation, when a location is read twice, has the same value for both reads, and “value is the same” is used to indicate “nothing has changed”. However, another thread can execute between the two reads and change the value, do other work, then change the value back, thus fooling the first thread into thinking “nothing has changed” even though the second thread did work that violates that assumption.
The ABA problem occurs when multiple threads (or processes) accessing shared memory interleave.
A common case of the ABA problem is encountered when implementing a lock-free data structure. If an item is removed from the list, deleted, and then a new item is allocated and added to the list, it is common for the allocated object to be at the same location as the deleted object due to optimisation. A pointer to the new item is thus sometimes equal to a pointer to the old item which is an ABA problem.