class Program { static void DownloadFile(object filename) { Console.WriteLine("开始下载:" +Thread.CurrentThread.ManagedThreadId +filename); Thread.Sleep(2000); Console.WriteLine("下载完成"); } static void Main(string[] args) { //Thread t = new Thread(DownloadFile);//创建出来Thread对象,这个线程并没有启动 //t.Start();//开始,开始去执行线程 //Console.WriteLine("Main"); //Thread t = new Thread(() => //{ // Console.WriteLine("开始下载:" + Thread.CurrentThread.ManagedThreadId); // Thread.Sleep(2000); // Console.WriteLine("下载完成"); //}); //t.Start(); //Thread t = new Thread(DownloadFile);//创建出来Thread对象,这个线程并没有启动 //t.Start("xxx.种子");//开始,开始去执行线程 //Console.WriteLine("Main"); //MyThread
C#通过Thread发起线程
于 2022-02-23 00:01:17 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)