title: Parallel.For does not wait all iterations
body: <p>I am building an optimization program using Genetic Algorithms. I used Parallel.For in order to decrease time. But it caused a problem which is same in code below:</p>
  
  <pre><code>class Program
      {
          static void Main(string[] args)
          {
              int j=0;
              Parallel.For(0, 10000000, i =&gt;
                  {
                      j++;
                  });
              Console.WriteLine(j);
              Console.ReadKey();
          }
      } 
  </code></pre>
  
  <p>Every time i run the program above, it writes a different value of j between 0 and 10000000. I guess it doesn't wait for all iterations to finish. And it passes to next line. 
  How am i supposed to solve this problem? Any help will be appreciated. Thanks. </p>
  
  <p>Edition:
  Interlocked.Increment(ref j); clause solves the unexpected results, but this operation causes about 10 times much more time when i compare with normal for loop.</p>