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
Since the link is no longer working here is the archived version
https://web.archive.org/web/20140325112655/http://lists.canonical.org/pipermail/kragen-tol/1999-August/000457.html