using System;
using System.IO;
using System.Threading ;
class MyThread{
public int count;
string thrdName;
public MyThread(string name){
count=0;
thrdName=name;
}
public void run(){
Console.WriteLine(thrdName+”starting.”);
do{
Thread.Sleep(500);
Console.WriteLine(“In”+thrdName+”, count is “+count);
count++;
}while(count<10);
Console.WriteLine(thrdName+” terminating.”);
}
}
class MultiThread{
public static void Main(){
Console.WriteLine(“Main thread starting.”);
MyThread mt=new MyThread(“Child #1”);
Thread newThrd=new Thread(new ThreadStart(mt.run));
newThrd.Start();
do {
Console.Write(“.”);
Thread.Sleep(100);
}while(mt.count!=10);
Console.WriteLine(“Main thread ending.”);
}
}
喵呜刷题:让学习像火箭一样快速,快来微信扫码,体验免费刷题服务,开启你的学习加速器!