![](/img/trans.png)
[英]Thread.Sleep() in C#: Does it sleep the thread the object was instantiated in, or the thread i am calling the method from?
[英]Calling Thread.sleep inside second Thread Object Method call
我不確定這將如何工作,我創建了一個Thread對象t1
並關聯了DoStuff
方法,在DoStuff
內部,我需要在某個時候調用Thread.Sleep(1000);
這將暫停t1
還是主線程,或者兩者都暫停。
var t1 = new Thread(new ThreadStart(DoStuff));
t1.Start();
public void DoStuff()
{
//some code then
Thread.Sleep(1000);
}
它肯定會暫停t1
線程,但是為什么不自己進行測試呢?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.