private static void DoTestBatch() { var thread = new Thread[100]; Pools.Add(thread); for (var i = 0; i < thread.Length; i++) { thread[i] = new Thread(ConnectAndTalk); } thread.AsParallel().ForAll(thread1 => { while (open > 100) { Thread.Sleep(250); } if (!cts.IsCancellationRequested) { thread1.Start(); } }); }