I have a global variable "mc" which has a value of 100 after the operation. if you run the method in a stream, then everything is fine, but if you run 2 streams, the value of "mc" will become 200. how to fix it?
if (mc.Count > 1)
{
System.Threading.Thread MyThread1 =
new System.Threading.Thread(delegate () { select_page(0, mc.Count / 2, 0); });
MyThread1.Start();
}
else
{
potoc1 = true;
}
System.Threading.Thread MyThread2 =
new System.Threading.Thread(delegate () { select_page(mc.Count / 2, mc.Count, 1); });
MyThread2.Start();
>Solution :
i had the same problem, add between running threads for
thread.sleep(50);