// Thread 1
// do A
x.store(1, std::memory_order_release); // operation1
// Thread 2
// do B
x.store(2, std::memory_order_release); // operation2
// Thread 3
x.load(std::memory_order_acquire); // operation3
我了解到,如果thread3读取thread1写入的值,则release和acquire操作是同步的,并且thread3的效果A
是可见的。
但如果是这样的话怎么办:
- 修改顺序为
x
1, 2 - thread3 读取 thread2 写入的值,因此 2发生在3 之前。
1 和 3 之间是否存在发生之前的关系?
或者本质上,修改顺序是否有助于发生之前的关系?