title: Is the "switch" statement evaluation thread-safe?
body: <p>Consider the following sample code:</p>
  
  <pre><code>class MyClass
  {
      public long x;
  
      public void DoWork()
      {
          switch (x)
          {
              case 0xFF00000000L:
                  // do whatever...
                  break;
  
              case 0xFFL:
                  // do whatever...
                  break;
  
              default:
                  //notify that something going wrong
                  throw new Exception();
          }
      }
  }
  </code></pre>
  
  <p>Forget the uselessness of the snippet: my doubt is about the behavior of the <code>switch</code> statement.</p>
  
  <p>Suppose that the <code>x</code> field could have only two values: <code>0xFF00000000L</code> or <code>0xFFL</code>. The switch above should not fall into the "default" option.</p>
  
  <p>Now imagine that one thread is executing the switch with "x" equal to 0xFFL, thus the first condition won't match. At the same time, another thread modifies the "x" variable to 0xFF00000000L. We know a 64-bit operation is not atomic, so that the variable will have the lower dword zeroed first, then the upper set afterward (or vice versa).</p>
  
  <p>If the second condition in the switch will be done when the "x" is zero (i.e. during the new assignment), will we fall into the undesired "default" case?</p>