Are generic.list and generic.dictionary a stream in .net

How to find out if a method is thread safe or not

For example, if I check http://msdn.microsoft.com/en-us/library/3wcytfd1.aspx , this does not indicate thread safety.

+6
source share
2 answers

No, they are not thread safe (without doing your own locking).

Instead, use one of Concurrent .

Stream Collections

The System.Collections.Concurrent namespace provides several thread-safe collection classes that should be used instead of the corresponding types in the System.Collections and System.Collections.Generic namespaces when multiple threads access the collection at the same time.

+10
source

The documentation for the entire List<T> class has a stream security segment:

Public static (Shared in Visual Basic) elements of this type are thread safe. Any instance members do not guarantee thread safety.

+3
source

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


All Articles