What is the difference between using explicit fences and std::atomic?
Although various answers cover bits and pieces of what the potential problem is and/or provide useful information, no answer correctly describes the potential issues for all three cases. In order to synchronize memory operations between threads, release and acquire barriers are used to specify ordering. In the diagram, memory operations A in thread 1 cannot … Read more