Lockfree Read value after Interlocked.Exchange?
问题 Lets say we have a class like so: public class Foo { private Bar bar = new Bar(); public void DoStuffInThread1() { var old = Interlocked.Exchange(ref bar,new Bar()); //do things with old //everything is fine here, I'm sure I have the previous bar value } public void OtherStuffFromThread2() { //how do I ensure that I have the latest bar ref here //considering mem cahces etc bar.Something(); } } And lets say we have two threads, one operating on DoStuffInThread1 and another on