using System; using System.Threading.Tasks; static class MyMainClass { static void Main(string[] args) { int counter = 0; Parallel.Invoke(() => { for (int i = 0; i < 1000000; ++i) { ++counter; } }, () => { for (int i = 0; i < 1000000; ++i) { --counter; } }); Console.WriteLine(counter); // not always 0.
{}