Im just wondering, is there a difference between how you increment a static variable in Java and C# in an threaded enviroment?
In Java you use atomic int:s to make this operation and in C# you use Interlocked.Incement(ref yourVar)
I by this dont mean the code you write but how it is actually locks the memory and does the actual increment.
Interlocked operation doest not lock memory, it rather emits LOCK prefix to the instruction depending on the operation. That cause processor to assert bus lock so only instruction is executed once. You can further look at the following article
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With