??   ???н????

?????????????????Thread1 sleep?????????????м??????????
???????????????????????????????????????????????е????????????????з????????????????ManualResetEvent????????????????????????????
????????????
using System;
using System.Threading;
namespace Threading
{
class Program
{
//???ManualResetEvent??????????????????
private static ManualResetEvent mre = new ManualResetEvent(false);
public static void Thread1(object data)
{
Console.WriteLine("Thread1 => {0}"??data.ToString());
if (Convert.ToInt32(data) == 9)
{
mre.Set();
}
}
static void Main(string[] args)
{
//???????????С
//?????????????????и???????????
//???????????????????? I/O ????????
ThreadPool.SetMaxThreads(3?? 3);
for (int i = 0; i < 10; i++)
{
//ThreadPool?????????????????
//ThreadPool.QueueUserWorkItem(new WaitCallback(Thread1)?? i);
ThreadPool.QueueUserWorkItem(Thread1?? i);
}
//???????????????? WaitHandle ??????????
mre.WaitOne(Timeout.Infinite?? true);
Console.WriteLine("Thread1 sleep");
Thread.Sleep(100000);
Console.WriteLine("Thread1 end");
Console.ReadKey();
}
}
}
????????????

????ok??????
?????ο??????
????ThreadPool??https://msdn.microsoft.com/zh-cn/library/system.threading.threadpool.aspx#Y0
????ManualResetEvent??https://msdn.microsoft.com/zh-cn/library/system.threading.manualresetevent.aspx
?????塢???
??????????????
???????????CPU???????????????????У?????????????????CPU??????????????????????????????????????????Ч???
????????????????棺
????????????????????????????棬????????????????
????????????Э???????????????CPU??????????
?????????????????????????????????????ù????????????
????????????????????????????????Bug??