2 ms·
C# has Interlocked https://learn.microsoft.com/en-us/dotnet/api/system.threading.interlocked?view=net-8.0 https://learn.microsoft.com/en-us/dotnet/api/system.th
by pjc50 2y ago
C# has Interlocked https://learn.microsoft.com/en-us/dotnet/api/system.threading.interlocked?view=net-8.0 https://learn.microsoft.com/en-us/dotnet/api/system.threadin... which is strictly better than volatile because it lets you write lockfree code that actually observes the memory semantics.
"Volatile" specifies nothing about memory barrier semantics in either Java or C++, if I remember correctly?
- gpderetta 2y agostd::atomic is equivalent of volatile in C++. C and C++ volatile is for other memory mapped I/O.