title: Locking thread vs process
body: <p>Here is a piece of sample code that uses locks:</p>
  
  <pre><code>public static class Account  
  {  
      decimal balance;  
      private static Object thisLock = new Object();  
  
      public static void Withdraw(decimal amount)  
      {  
          lock (thisLock)  
          {  
              if (amount &gt; balance)  
              {  
                  throw new Exception("Insufficient funds");  
              }  
              balance -= amount;  
          }  
      }  
  } 
  </code></pre>
  
  <p>Lets say this method is called by an web api. And the API is hosted on IIS. My understanding is that when a request is received by IIS, a new worker process can be created. So if two concurrent requests are received, and if they are being are executed on two separate processes, then the above lock is quite useless and I need to use some kind of inter-process blocking. Is my understanding correct? </p>