可能重复:
Is there any reason to lock on something other than new object()?
我想知道锁定的最佳私有静态对象是什么,如果确实存在差异。
目前,我的大部分代码都是:
private static object m_lockObject = new object();
lock(m_lockObject)
{
..critical thread code here
}
我应该使用不同的类型,而不是只锁定一个对象?像自定义类实例,int或字符串等......?或者没关系?
由于