I have a problem with multi-thread Below is my c# code:
    private static readonly object ThreadKey = new object();
    private void PlayVideo()
    {
        int count = 0;
        for (int y = 1; y < 1000; y++)
        {
            lock(ThreadKey)
            {
                count++;
                if ((count % 100) == 0)
                {
                    Task.Run(() => TestTh(count));
                }
            }
         
        }
    }
    private void TestTh(int count)
    {
        //i find count is not a multiple of 100
        System.IO.File.WriteAllText(@"D:\USER\Desktop\Myfolder\" + count.ToString()+".txt", count.ToString());
    }
i find the variable 'count' in TestTh() function is not a multiple of 100 Can anyone explain this phenomenon?
please help me,thanks
I have locked count ,but it is not work
 
    