So I have Dictionary<string, SomeClass> which will be accessed heavily by multiple concurrent threads – some will write, most will read. No locks, no synchronization – worker thread will make no checks – simply read or write. The only guarantee is that no two threads will write value with same key. The question is could this data structure become corrupted this way? By corrupted I mean not working anymore even with one thread.
So I have Dictionary<string, SomeClass> which will be accessed heavily by multiple concurrent threads
Share
The worst-case scenarios include:
NullReferenceException or IndexOutOfRangeException thrown out of a Dictionary<,> method.
An arbitrary amount of data is lost. If two threads attempt to resize the Dictionary<,> table at the same time, they can stomp on each other, screw up, and lose data.
Wrong answer is returned by a read from the Dictionary<,>.
Basically, the Dictionary<,> can do just about anything bad you can think of, within the limits imposed by the CLR. Presumably, you still won’t break type safety or corrupt the heap as you could in a native programming language. Probably, anyways 🙂