title: Are IEnumerable Linq methods thread-safe?
body: <p>I wonder if Linq extension methods are atomic? Or do I need to <code>lock</code> any <code>IEnumerable</code> object used across threads, before any sort of iteration?</p>
  
  <p>Does declaring the variable as <code>volatile</code> have any affect on this?</p>
  
  <p>To sum up, which of the following is the best, thread safe, operation?</p>
  
  <p><strong>1- Without any locks:</strong></p>
  
  <pre><code>IEnumerable&lt;T&gt; _objs = //...
  var foo = _objs.FirstOrDefault(t =&gt; // some condition
  </code></pre>
  
  <p><strong>2- Including lock statements:</strong></p>
  
  <pre><code>IEnumerable&lt;T&gt; _objs = //...
  lock(_objs)
  {
      var foo = _objs.FirstOrDefault(t =&gt; // some condition
  }
  </code></pre>
  
  <p><strong>3- Declaring variable as volatile:</strong></p>
  
  <pre><code>volatile IEnumerable&lt;T&gt; _objs = //...
  var foo = _objs.FirstOrDefault(t =&gt; // some condition
  </code></pre>