.net4.0的TPL(Task Parallel Library)可以访问线程池。
在此之前,访问线程池的方法主要有2种。
ThreadPool.QueueUserWorkItem和异步委托。
static void Main(string[] args)
{
ThreadPool.QueueUserWorkItem(Go);
ThreadPool.QueueUserWorkItem(Go, 123);
Console.ReadLine();
}
static void Go(object data) // data will be null with the first call.
{
Console.WriteLine("Hello from the thread pool! " + data);
}
本文转自cnn23711151CTO博客,原文链接:http://blog.51cto.com/cnn237111/519051
,如需转载请自行联系原作者