Can multiple threads change a dictionary?

In C #, can multiple threads read and write to the dictionary if each thread accesses only one element in the dictionary and never accesses the other?

+3
source share
2 answers

No, the dictionary is not thread safe.

Except for changing the contents of the reference type (object), which is stored as a value in the dictionary.

In .NET 4 we will have System.Collections.Concurrent.ConcurrentDictionary.

+4
source

No, they cannot. A dictionary is not thread safe:

(TKey, TValue) , . , - . , , . , .

+3

Source: https://habr.com/ru/post/1740272/


All Articles