日期:2014-05-18 浏览次数:20930 次
static void Main(string[] args)
{
time = DateTime.Now.AddSeconds(10);
Thread th = new Thread(new ParameterizedThreadStart(delegate (object obj)
{
while (true)
{
if (DateTime.Now >= time)
{
Console.WriteLine("Time up");
return;
}
}
}));
th.Start();
}
static DateTime time;
------解决方案--------------------
3楼的那个线程一直是满负荷的 我觉得 在while中sleep 500毫秒 也是没关系的,但是可以严重的缓解CPU压力