using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;
namespace 线程测试{ class MyInterrupt { public static Thread sleeper; public static Thread awaker; public void SleepThread() { for (int i = 1; i < 10; i++) { Console.Write(i + ","); if (i == 4 || i == 8) { Console.WriteLine("Thread is sleep at" + i); try { Thread.Sleep(20);//有点像Timer控件,掐时间跑程序而已,哪里体现两个线程的优点? } catch (ThreadInterruptedException e) { Console.WriteLine("Thread is interrupted"+"异常了!"+e.Message); }
} } } public void AwakeThread() { for(int i=10;i
- 5 回答
- 0 关注
- 340 浏览
添加回答
举报
0/150
提交
取消