title: lock not working in C#
body: <p><code>Lock</code> is not working as expected, here is the code.
  I am applying thread here, but I will apply it to <strong>ASP.NET</strong> application.</p>
  
  <pre><code>class Program
      {
          static void Main(string[] args)
          {
              ThreadManager.CurrentSession = 0;
              for (int i = 0; i &lt; 10; i++)
              {
                  CreateWork objCreateWork = new CreateWork();
                  ThreadStart start = new ThreadStart(objCreateWork.ProcessQuickPLan);
                  new Thread(start).Start();
              }
              Console.ReadLine();
          }
      }
  
      class CreateWork
      {
          private object CurrentSession = -1;
          public void ProcessQuickPLan()
          {
              lock (CurrentSession)
              {
                  CurrentSession = ThreadManager.CurrentSession;
                  Console.WriteLine(CurrentSession);
                  ThreadManager.CurrentSession = Convert.ToInt32(ThreadManager.CurrentSession) + 1;
              }
          }
      }
  
      class ThreadManager
      {
          public static object CurrentSession
          {
              get;
              set;
          }
      }
  </code></pre>
  
  <p>It is giving me following output</p>
  
  <pre><code>0
  0
  0
  3
  4
  4
  6
  7
  8
  9
  </code></pre>
  
  <p>And I am expecting</p>
  
  <pre><code>0
  1
  2
  3
  4
  5
  6
  7
  8
  9
  </code></pre>
  
  <p>Where am I doing wrong?</p>
  
  <p>Should I use <code>readonly object</code> as described here  <a href="https://stackoverflow.com/questions/10143557/c-sharp-lockmylocker-not-work">C# lock(mylocker) not work</a></p>