is it safe to apply double-checked locking to Dictionary?
<p>Is it safe to apply double-checked locking to <code>Dictionary</code>?</p>

<p>I.e. if it safe to call <code>TryGetValue</code> and other "get/contains" methods from different threads? (without calling other, non-get methods).</p>

<p><strong>upd</strong> Would collection be safe for N readers AND 1 writer? Assume In cycle 10 threads are try to access element with key X using double-checked locking and if accessed they just remove it. At some point I do add element with key X from one another thread (using lock). I expect that exactly one reader should obtain this element and delete it.</p>

<p><strong>upd2, about answer</strong> so my question is confusing. actually I've asked two questions:</p>

<ol>
<li>if it safe to call <code>TryGetValue</code> and other "get/contains" methods from different threads? (without calling other, non-get methods).</li>
<li>Would collection be safe for N readers AND 1 writer?</li>
</ol>

<p>The answer for first question is Yes and the answer for second question is No.</p>

<p>So sometimes it's safe to <code>apply double-checked locking</code> sometimes it is not. It depends on if you are writing at the same time to a collection.</p>
