Whats the difference between an upgradeable read lock and a write lock in the ReaderWriterLock class?
Based on the MSDN description, only one thread can enter an upgradeable read lock. If I follow correctly, I could just forget about upgrading it since its the same as a write lock.
Anything I’m missing?
(I’m assuming you mean
ReaderWriterLockSlim, as I don’t thinkReaderWriterLockhas an upgradeable read mode.)Although only one thread can enter an upgradeable read lock, one thread can have an upgradeable read lock and other threads can still enter a read lock:
Compare that with a write lock:
In other words, a write lock is entirely exclusive, whereas an upgradeable read lock will allow other threads to keep entering/exiting for read mode until the upgrade is needed.