【发布时间】:2015-03-25 09:04:30
【问题描述】:
以下两个代码sn-ps哪个好用?
static readonly object _locker = new object();
lock (_locker)
或
lock (this)
this 是当前实例的对象。那么为什么lock (_locker) 总是在书中呢?
相关:
What is the difference between lock(this) and lock(thisLock)?
Why is lock(this) {…} bad?
【问题讨论】:
标签: c# .net multithreading locking thread-safety