using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace ThreadPoolExample { class Program { static void DoWork(object o) { int i = (int)o; //in general, we should test whether o is int Console.WriteLine("Thread {0} is starting", i); Thread.Sleep(3000); Console.WriteLine("Thread {0} is stopping", i); } static void Main(string[] args) { ThreadPool.SetMaxThreads(3,3); for (int i = 1; i < 10; i++) { ThreadPool.QueueUserWorkItem(DoWork, i); } Thread.Sleep(20000); } } }