"Ensuring Atomicity for Increment"

private static readonly object staticMutationLock = new object();
	
private static void WriterThreadEntry() {
	for (int i = 0; i < INCREMENT_PER_THREAD; ++i) {
		lock (staticMutationLock) {
			sharedState++;
		}
	}
}


Code snippet taken from "Common Multithreading Mistakes in C# - III: Unsafe Assumptions".