Concurrent Dictionary Correct Usage

It depends on what you mean by thread-safe.

From MSDN – How to: Add and Remove Items from a ConcurrentDictionary:

ConcurrentDictionary<TKey, TValue> is designed for multithreaded scenarios. You do not have to use locks in your code to add or remove items from the collection. However, it is always possible for one thread to retrieve a value, and another thread to immediately update the collection by giving the same key a new value.

So, it is possible to get an inconsistent view of the value of an item in the dictionary.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)