Why does the lock insure that the underlying monitor is released and direct usage of monitor does not?
问题 The msdn article Thread Synchronization (C# Programming Guide) specifies that: lock (x) { DoSomething(); } is equivalent to: System.Object obj = (System.Object)x; System.Threading.Monitor.Enter(obj); try { DoSomething(); } finally { System.Threading.Monitor.Exit(obj); } and then that: "Using the lock keyword is generally preferred over using the Monitor class directly, ... because lock insures that the underlying monitor is released, even if the protected code throws an exception " Does this