title: using interlocked usage
body: <p>I am trying to write a multithreaded program where each thread would use a counter and then increment it.</p>
  
  <p>for example:</p>
  
  <pre><code>lock(this)
  {
     counter++;
     Console.WriteLine(counter); 
  }
  </code></pre>
  
  <p>i know that for incrementation i can use:</p>
  
  <pre><code>System.Threading.Interlocked.Increment(counter);
  </code></pre>
  
  <p>but what about locking for both incrementing and doing something with the counter?</p>
  
  <p>Thanks!</p>