多线程处理

  while (true)
            {
                Thread.Sleep(1000);//
这句写着,主要是没必要循环那么多次。去掉也可以。
                int maxWorkerThreads, workerThreads;
                int portThreads;
                ThreadPool.GetMaxThreads(out maxWorkerThreads, out portThreads);
                ThreadPool.GetAvailableThreads(out workerThreads, out portThreads);
                if (maxWorkerThreads - workerThreads == 0)
                {
                    Console.WriteLine("
结束了");
                    break;
                }
            }

posted @ 2012-03-22 20:40  欢喜王子  阅读(182)  评论(0编辑  收藏  举报