"Variable Caching Example - JIT Rewrite"

private static void LoopThreadStart() {
	if (!cancelLoop) {
		while (true) {
			++counter;
		}
	}
}


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