关于C#线程池,感觉好难啊
using System;
using System.Threading;
class Program
{
static AutoResetEvent ev = new AutoResetEvent(false);
public static int Main(string[] args)
{
ThreadPool.RegisterWaitForSingleObject(ev,new WaitOrTimerCallback(WaitThreadFunc),4,2000,false);
ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadFunc), 8);
Thread.Sleep(10000);
return 0;
}
public static void ThreadFunc(object b)
{
Console.WriteLine("the object is {0}", b);
for (int i = 0; i < 2; i++)
{
Thread.Sleep(1000);
ev.Set();
}
}
public static void WaitThreadFunc(object b, bool t)
{
Console.WriteLine("the object is {0},t is {1}", b, t);
}
}
这个程序有人帮忙解释下吗?