public static void Main() { int i, N = 1000; Client[] clients = new Client[N]; for (i = 0; i < N; ++i) { clients[i] = new Client(i); clients[i].Connect("127.0.0.1"); Thread.Sleep(1); } Thread.Sleep(1000); while (true) { bool live = false; foreach (Client cli in clients) { if (cli.Finished) continue; cli.Update(); if (cli.IsRunning) { cli.Pause(); Thread.Sleep(1); } else { cli.Resume(); cli.SendEcho(); } if (!live) live = true; } if (!live) break; for (i = 0; i < 3; ++i) { foreach (Client cli in clients) { cli.Update(); } Thread.Sleep(5); } } }