The problem in your example is that you are using a non-atomic way (and therefore not thread-safe) of updating variable 'x'. The "+=" operator (i.e. The addition assignment operator) is not atomic as it involves a read of the variable and then an assignment to the variable. If you have multiple threads using the "+=" operator then they may interleave read and write operations ,or perform them at the same time, and so update values in unintended ways - a classic race condition.
For example, two threads may read variable 'x' value as 1, and then both update the value to 2.
If you are updating any shared state you should use atomic operations so that multiple threads do not see intermediary values in what you intend to be a single compound operation.
For your example which is incrementing variable 'x', you can use the Interlocked API:
Parallel.For(0, 100, i => Parallel.For(i + 1, 100, a => Interlocked.Increment(ref x)));
This will guarantee that the increment of variable 'x' is carried our atomically.