class Program
    {
          private static volatile bool bChanged;
          static void Main(string[] args)
          {
                Thread t1 = new Thread(run1);
                Thread t2 = new Thread(run2);
                t1.Start();
                t2.Start();
                Console.Read();
          }
          public static void run1()
          {
                for (; ; )
                {
                      if (bChanged == !bChanged)
                      {
                            Console.WriteLine("!=");
                            // System.exit(0);
                      }
                }
           }      
          public static void run2()
          {
                for (; ; )
                {
                      bChanged = !bChanged;
                }
          }
    }

C# volatile 的使用_System