static void Main(string[] args)
{
//设置线程池中的线程数最大为1000,第一个为工作者线程,第二个为I/O线程
ThreadPool.SetMaxThreads(1000, 1000);
for (int i = 0; i < 10;i )
{
ThreadPool
.QueueUserWorkItem(new WaitCallback
(ShowMessage
),
string.Format("当前编号{0}",i
));
}
Console.ReadLine();
}
//带参数 无返回值
static void ShowMessage(object x)
{
string current = string.Format("当前线程id为{0}", System.
Threading.Thread.CurrentThread.ManagedThreadId);
//等待1秒钟
System.Threading.Thread.Sleep(1000);
Console.WriteLine(string.Format("{0},输入为{1}", current, x));
}
//csharp/6982