title: Is this Comparer class from SSCLI library code ThreadSafe?
body: <pre><code>public abstract class Comparer&lt;T&gt; : IComparer, IComparer&lt;T&gt;
      {
          static Comparer&lt;T&gt; defaultComparer;    
  
          public static Comparer&lt;T&gt; Default {
              get {
                  Comparer&lt;T&gt; comparer = defaultComparer;
                  if (comparer == null) {
                      comparer = CreateComparer();
                      defaultComparer = comparer;
                  }
                  return comparer;
              }
          }
  </code></pre>
  
  <p>First, is the Default property thread safe?
  Isn't it possible that effect of the following statement</p>
  
  <pre><code>comparer = CreateComparer(); 
  </code></pre>
  
  <p>might not be visible to threads other than creating thread?
  So, multiple instances of  Comparer are constructed?</p>
  
  <p>Is Microsoft doing this for the sake of trading synchronization cost off with the cost of 
  creating multiple objects?</p>
  
  <p>Second why defaultComparer is first assigned to comparer variable first...and then later on swapped?
  why do Comparer comparer = defaultComparer?</p>