title: Why my Thread does not stop?
body: <p>I have the following code, where I start a <code>Thread</code> using a <code>ParameterizedThreadStart</code> object as constructor argument:</p>
  
  <pre><code>static object obj = new object();
  
  static void Main(string[] args)
  {
      ParameterizedThreadStart start = (o) =&gt;
      {
          ThreadTest(o);
      };
  
      var t = new Thread(() =&gt; start(obj));
      t.Name = "t";
      t.Start();
  
      Thread.Sleep(3000);
      obj = null;
  
      // Why the Thread (t) continue here??
      Console.ReadKey();
  }
  
  
  private static void ThreadTest(object o)
  {
      while (o != null)
      {
          Console.WriteLine(Thread.CurrentThread.Name);
          Thread.Sleep(1000);
      }
  }
  </code></pre>
  
  <p>After I set <code>obj</code> to <code>null</code> in the <code>ThreadTest</code> method the argument <code>o</code> is still a valid object, why?<br>
  How can I set the argument <code>o</code> to <code>null</code> using <code>obj</code>?</p>
  
  <p><a href="http://msmvps.com/blogs/peterritchie/archive/2007/08/22/thead-abort-is-a-sign-of-a-poorly-designed-program.aspx" rel="nofollow">I would prefer not to use Thread.Abort</a></p>