本文介绍了如何使较新的线程进入睡眠状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
—SA
"Not working" means: it won''t compile. That''s correct.
The method System.Threading.Thread.Sleep is static. You don''t need a thread reference to indicate what thread should be effected: the thread to be put to sleep is the current thread. In this way, a code thread can put to sleep only the same thread running this code. This is a common paradigm of all threaded systems.
—SA
我已将线程创建为
I have created thread as
Thread th = new Thread(DoSomething); th.IsBackground = true;但th.sleep();无法正常工作 但同时主线程
but th.sleep(); not working but at the same time main thread
System.Threading.Thread.Sleep(1000);工作正常 请建议
working fine Please suggest
推荐答案不起作用"的意思是:它将无法编译.没错. 方法System.Threading.Thread.Sleep是静态的.您不需要线程引用来指示应该执行哪个线程:要进入睡眠状态的线程是当前线程.这样,代码线程只能使运行该代码的同一线程进入睡眠状态.这是所有线程系统的常见范例.
更多推荐
如何使较新的线程进入睡眠状态
发布评论