Critical Blocks and Improper Lock Objects
Quick catch-up… critical application blocks are blocks of code that can only be executed by one thread at a time. Stock example for illustration:
public static class SmackTracker { private static int smackCount = 0; private static object locker = new object(); public static void HitItAgain() { lock (locker) { smackCount++; } } }
No matter how many threads call this method, the smackCount will only be incremented by one thread at a time, but this is not a post on the value and usage of thread locking…