In .NET 4 you have the ConcurrentDictionary class.
If you need to use an older version of .NET, and want to write it yourself:
- wrap a Dictionary as a private field in your class
- use a separate
private object lockObject
- take a lock on that
lockObject
around every access to the dictionary