for (int i = 0; i < 3; i++) { Thread th = new Thread(new ThreadStart(delegate { 过马路(i, "xxxxx路"); })); th.Start(); Thread.Sleep(4); }
1.创建线程,并启动
2.进入匿名委托,
3.执行过马路方法
4.执行完成后从过马路方法中跳出,跳回TreadStart方法中,
5.跳出当前线程对象,销毁线程.
for (int i = 0; i < 3; i++) { Thread th = new Thread(new ThreadStart(delegate { 过马路(i, "xxxxx路"); })); th.Start(); Thread.Sleep(4); }
1.创建线程,并启动
2.进入匿名委托,
3.执行过马路方法
4.执行完成后从过马路方法中跳出,跳回TreadStart方法中,
5.跳出当前线程对象,销毁线程.