Refer:
Http://msdn.microsoft.com/zh-cn/library/system.threading.threadpool (VS.80). aspx
Http://www.codeproject.com/KB/threads/threadtests.aspx
Http://www.codeproject.com/KB/threads/smartthreadpool.aspx
Http://blog.zhaojie.me/2009/07/thread-pool-1-the-goal-and-the-clr-thread-pool.html)
Jeffrey Richter <CLR via C #> 3rd Edition
First, let's take a look at the Main code of the Main method of the console application:
001
static
bool
done =
false
;
002
static
decimal
count2 = 0;
003
static
int
threadDone = 0;
// Indicates the number of threads enabled?
004
static
System.Timers.Timer timer =
new
System.Timers.Timer(1000);
005
006
static
decimal
[] threadPoolCounters =
new
decimal
[10];
007
static
Thread[] threads =
new
Thread[10];
008
static
System.Timers.Timer[] threadTimers =
new
System.Timers.Timer[10];
009
010
static
void
Main(
string
[] args)
011
{
012
timer.Stop();
013
/* When AutoReset is set to false, Timer only triggers an Elapsed event after the first Interval.
014
To keep the Elapsed events triggered at Interval intervals, set AutoReset to true. */
015
timer.AutoReset =
false
;
016
timer.Elapsed +=
new
ElapsedEventHandler(OnTimerEvent);
// Trigger the event when timer. Start ()
017
decimal
total = 0;
018
019
// raw test
020
decimal
count1 = SingleThreadTest();
// A single thread to the end
021
Console.WriteLine(
"Single thread count = "