Any downsides to locking a collection vs. a syncRoot?
问题 I'm wondering if there are any downsides to locking over a collection such as a List<T> , HashSet<T> , or a Dictionary<TKey, TValue> rather than a simple object . Note: in the following examples, that is the only place where the locks occur, it's not being locked from multiple places, but the static method may be called from multiple threads. Also, the _dict is never accessed outside of the GetSomething method. My current code looks like this: private static readonly Dictionary<string, string