






















转 http://msdn2.microsoft.com/en-us/library/hf5de04k(VS.71).aspx
如果x是对象就不会报错
object x = new object();
// The next line creates a generic object containing the value of
// x each time the code is executed, so that Enter never blocks.
Monitor.Enter(x);
try {
// Code that needs to be protected by the monitor.
}
finally {
// Always use Finally to ensure that you exit the Monitor.
// The following line creates another object containing
// the value of x, and throws SynchronizationLockException
// because the two objects do not match.
Monitor.Exit(x);
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。