thread.Join(); 让主线程等待自己完成
生活随笔
收集整理的這篇文章主要介紹了
thread.Join(); 让主线程等待自己完成
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;namespace ConsoleApplication1
{class Program{private static void Method(){Thread.Sleep(5000);Console.WriteLine("當(dāng)前線程:" + Thread.CurrentThread.Name);}static void Main(string[] args){Thread.CurrentThread.Name = "MainThread";Thread thread = new Thread(Method);thread.Name = "Thread";thread.Start();//會阻止主線程,直到thread線程終結(jié)(線程方法返回或線程遇到異常)//輸出:當(dāng)前線程:Thread// 主線程:MainThread//可以注銷此句對比輸出結(jié)果
thread.Join();Console.WriteLine("主線程:" + Thread.CurrentThread.Name);Console.Read();}}
}
?
轉(zhuǎn)載于:https://www.cnblogs.com/qqhfeng/p/4769662.html
總結(jié)
以上是生活随笔為你收集整理的thread.Join(); 让主线程等待自己完成的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IOS上 关于状态栏的相关设置(UISt
- 下一篇: ios uitableview 去掉多余