I\'m just looking in to the new .NET 4.0 features. With that, I\'m attempting a simple calculation using Parallel.For and a normal for(x;x;x) loop.
sum += y; is actually sum = sum + y;. You are getting incorrect results because of the following race condition:
sumsumsum+y1, and stores the result in sumsum+y2, and stores the result in sumsum is now equal to sum+y2, instead of sum+y1+y2.