Example #1
0
 public void startCounting(int times, TotalCount thisOne)
 {
     for (int i = 0; i < times; i++)
     {
         thisOne.count++;
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            TotalCount ThisWillGoWrong = new TotalCount();

            Counter Counterone = new Counter();
            Counter CounterTwo = new Counter();

            Thread one = new Thread(() => Counterone.startCounting(20000, ThisWillGoWrong));
            Thread two = new Thread(() => CounterTwo.startCounting(50000, ThisWillGoWrong));

            one.Start();
            two.Start();


            System.Console.WriteLine(ThisWillGoWrong.count);
        }