title: Dictionary Update Thread-Safety
body: <p>Is the following code thread safe?</p>
  
  <pre><code>var dict = new Dictionary&lt;int, string&gt;()
      { { 0, "" }, { 1, "" }, { 2, "" }, { 3, "" } };
  
  var nums = dict.Keys.ToList();
  
  Parallel.ForEach(nums, num =&gt;
              {
                  dict[num] = LongTaskToGenerateString();
              });
  
  return dict;
  </code></pre>