How using readerwriterlock correctly <p>Hello i need to use writerreaderlock in my method. I want to know how use it correctly.</p> <p>I got a dictionary of ObjectA</p> <pre><code>public class ObjectA { public ReaderWriterLock RWL {get;set;} public ObjectB obj {get;set;} public ObjectA() { RWL = new ReaderWriterLock(); } } public class ObjectB { int TTL {get;set;} string Value {get;set;} } </code></pre> <p>In my method I use a dictionary of ObjectA, the key is a Guid, so presume that when i call dict[guid] it always return an instance of my ObjectA (for the exemple)</p> <pre><code>public foo() { ObjecA objA = dict[guid]; objA.RWL.AcquireReaderLock(500); if(objA.obj.TTL&lt;=0) { objA.obj.RWL.AcquireWriterLock(1000); objA.obj.Value = DateTime.Now().ToString(); objA.obj.RWL.ReleaseWriterLock(); }else{ int ttl = objA.obj.TTL; Interlocked.Decrement(ref ttl); } objA.RWL.ReleaseReaderLock(); } </code></pre> <p>I am really not sure of my using of reader and writer over there, how did i need to use reader writer lock, with a conditional validation ?</p>