In many MSDN documents, this is written under the Thread Safety heading;
\"Any public static (Shared in Visual Basic) members of this type are thread safe. Any instanc
To understand this, consider the following example. In MSDN description of .net class HashSet, there is a part that says about the thread safety. In the case of HashSet Class, MSDN says “Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.” Of cause we all know the concept of race conditions and deadlocks, but what does Microsoft wants to say in simple English? If two threads add two values to an “instance” of a HashSet there are some situation where we can get its count as one. Of cause in this situation the HashSet object is corrupted since we now have two objects in the HashSet, yet its count shows only one. However, public static version of the HashSet will never face such a corruption even if two threads concurrently add values.