So I’m reading about synchronization in .NET and a curiosity hit me. When you have multiple objects READING on the same data you should use ReaderWriterLock.AcquireReaderLock to ensure that no other object modifies the data while there’s a lock in it.
Now… If I’m sure that no object will modify the data (while it’s being read at least) does it make sense to acquire a ReaderLock? Or is it advised to use and why?
Theoretically, if you’re 100% positive that nothing is going to modify the data while your readers are reading the data, then no, it’s not necessary to get a reader-lock. A reader-lock is used to prevent writers from modifying the data while it’s being read, but still allows multiple readers to access that data concurrently.
According to the MSDN documentation: