using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading ; namespace 多线程 { class 线程池 { public static void Main() { int workNums ; int ioNums ; ThreadPool.GetMaxThreads( out workNums , out ioNums ) ; Console.WriteLine( "工作线程数{0} , IO线程数{1}" , workNums , ioNums ) ; for( int i = 0 ; i < 10 ; i ++ ) { ThreadPool.QueueUserWorkItem( JobForAThread ) ; } Console.ReadLine() ; } static void JobForAThread( object state ) { for( int i = 0 ; i < 3 ; i ++ ) { Console.WriteLine( "loop {0} , running inside pooled thread {1} " , i , Thread.CurrentThread.ManagedThreadId ) ; Thread.Sleep( 9000 ) ; } } } }