title: Is the following C# code thread safe?
body: <p>I am trying to learn the threading in C#. Today I sow the following code at <a href="http://www.albahari.com/threading/" rel="nofollow">http://www.albahari.com/threading/</a>:</p>
  
  <pre><code>class ThreadTest
  {
    bool done;
  
    static void Main()
    {
      ThreadTest tt = new ThreadTest();   // Create a common instance
      new Thread (tt.Go).Start();
      tt.Go();
    }
  
    // Note that Go is now an instance method
    void Go() 
    {
       if (!done) { done = true; Console.WriteLine ("Done"); }
    }
  }
  </code></pre>
  
  <p>In Java unless you define the "done" as volatile the code will not be safe. How does C# memory model handles this?</p>
  
  <p>Guys, Thanks all for the answers. Much appreciated. </p>