C # multithreaded reading of non-modifiable collections

I have a dictionary that populates once in a static constructor and has remained unchanged since. I want multiple threads to be able to read values ​​from this collection. Do I need a lock here?

+5
source share
3 answers

According to Microsoft's documentation, the Dictionary class can support multiple readers at the same time, until the collection changes. Therefore, no locks are required.

+14
source

. , . , - , , , , .

, . , , - , .

+2

: , , . , , , .


- . , . , , .

, , , . , . , , , .

, , , , , , . , , .

, , , , .

+1

All Articles