public static void Main(string[] args) { NumberCounter nc = new NumberCounter(); Thread t1 = new Thread(Run4); Thread t2 = new Thread(Run4); t1.Start(nc); t2.Start(nc); }
public static void Run4(object o) { NumberCounter nc = (NumberCounter)o; for (int i = 0; i < 100; i++) { lock (nc) { nc.Change(); nc.Show(); } Thread.Sleep(100); } }