title: C# version of java's synchronized keyword?
body: <p>Does c# have its own version of the java "synchronized" keyword? </p>
  
  <p>I.e. in java it can be specified either to a function, an object or a block of code, like so:</p>
  
  <pre><code>public synchronized void doImportantStuff() {
     // dangerous code goes here.
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>public void doImportantStuff() {
     // trivial stuff
  
     synchronized(someLock) {
        // dangerous code goes here.
     }
  }
  </code></pre>