1. 利用Thread start启动线程
ThreadStart表示执行线程的方法
ThreadStart(delegate(){})
public static void testThread()
{
int Max_Thread_Count = 10;
long currentThreadCount = 0;
for(var i = 0;i < 100;i ++)
{
var ii = i;
while(true)
{
if (Interlocked.Read(ref currentThreadCount) < Max_Thread_Count)
break;
Thread.Sleep(1000);
}
Interlocked.Increment(ref currentThreadCount);
new Thread(new ThreadStart(delegate()
{
Thread.Sleep(1000);
Console.WriteLine("Current position is " + ii);
Thread.Sleep(1000);
Interlocked.Decrement(ref currentThreadCou