另一方面,如果锁被占有很长时间,那么自旋的线程只会消耗CPU而不做任何有用的工作,因此带来浪费。
On the other hand, if the lock is held for a longer time, spinning is wasteful as the spinning thread consumes CPU without doing anything useful.
它较悲观会话锁更弱一些,相关方约定发出警告,而不是阻止。
This is weaker than a pessimistic session lock -- the convention adhered to by the participants is to warn, not to block.
另一方面,我们又不希望分配太多锁对象,特别是在ConcurrentDictionary最后只存储了很少项目的时候。
On the other hand, we don't want to allocate too many lock objects, especially if the ConcurrentDictionary only ends up storing only a small number of items.
应用推荐