![](/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.