Suppose I have an AtomicInteger value, ai. In thread T1, I do:
x = 42 // x is a non-volatile shared integer
ai.lazySet(0);
AFAIK, in another thread if ai.get() returns 0, the write x=42 will also be visible.
Now, in another thread T2 (after T1 is run), I do:
ai.lazySet(1);
Will setting x=42 from T1 be visible after this operation?
My reading of this is that: If, in T2, ai.get() returns 0 before you call ai.lazySet(1), then the x=42 write will also be visible in T2.
This is the transitivity property of happens-before from the JMM.
I don’t think you can get any stronger guarantees than that from the JMM. However, in practice, real JVMs may do better.