Last active
August 29, 2015 14:18
-
-
Save lomomike/566d7e65a4ddfd4d26f5 to your computer and use it in GitHub Desktop.
Incorrect lock usage - SynchronizationLockException guarantee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
private static object locker = new object(); | |
static void Main(string[] args) | |
{ | |
Monitor.Enter(locker); | |
Console.WriteLine("In Main Thread"); | |
ThreadPool.QueueUserWorkItem((o) => { | |
Console.WriteLine("In New Thread"); | |
Monitor.Exit(locker); | |
}); | |
Console.ReadKey(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment