Why does using volatile produce a different result?
<pre><code>    private const int Total = 500000;
    private static volatile int _count = 0;

    private static void Main()
    {
        Task task = Task.Factory.StartNew(Decrement);
        for (int i = 0; i &lt; Total; i++)
        {
            _count++;
        }

        task.Wait();
        Console.WriteLine(_count);

        Console.ReadLine();
    }

    private static void Decrement()
    {
        for (int i = 0; i &lt; Total; i++)
        {
            _count--;
        }
    }
</code></pre>

<p>Sometimes the result is 0,sometimes the result is -xxxxxx. I don't know why. Can anybody explain it and tell me the correct usage.</p>
