title: This code hangs in release mode but works fine in debug mode
body: <p>I came across this and want to know the reason for this behavior in debug &amp; release mode.</p>
  
  <pre><code>public static void Main(string[] args)
  {            
     bool isComplete = false;
  
     var t = new Thread(() =&gt;
     {
         int i = 0;
  
          while (!isComplete) i += 0;
     });
  
     t.Start();
  
     Thread.Sleep(500);
     isComplete = true;
     t.Join();
     Console.WriteLine("complete!");
  }
  </code></pre>