Is the 'volatile' keyword still broken in C#?
问题 Joe Albahari has a great series on multithreading that's a must read and should be known by heart for anyone doing C# multithreading. In part 4 however he mentions the problems with volatile: Notice that applying volatile doesn’t prevent a write followed by a read from being swapped, and this can create brainteasers. Joe Duffy illustrates the problem well with the following example: if Test1 and Test2 run simultaneously on different threads, it’s possible for a and b to both end up with a