Quick multithreading question...
I have a single dictionary object in memory containing about 20,000 items. If I have multiple threads attempting to read from this object, would you expect this to create a bottleneck?
NET 3.5 . Dictionary object would be read only
Dictionary is ReadOnly so I'm not concerned about read/writes, only performance.
It won't create a bottleneck but a dictionary is not thread safe so you might not get the expected results. In .NET 4.0 you could use ConcurrentDictionary<TKey, TValue>
for this purpose.
If it's a readonly dictionary then it's probably safe to have concurrent readers, just make sure that you fill this dictionary with data in a static constructor to make sure that writing doesn't interfere with reading and it takes place before any thread tries to read.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With