线程问题 [英] Probleme with Threads
本文介绍了线程问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们,
我需要帮助来创建10个线程,当这些线程结束工作时,它们将被杀死,而在我创建另外10个线程后,执行相同的方法并像这样...
每次我必须这样做时,
Thx
Hi friends,
I want help to create 10 Threads, and when these threads end work they will be killed, and after I create another 10 execute the same methode and like that...
every time i have to do this,
Thx
推荐答案
线程是昂贵的资源,您应该创建并重用它们.
请参见 ThreadPools 和如何:使用线程池(C#编程指南)
Threads are expensive resources, and you should create and reuse them.
See the following link on ThreadPools and How to: Use a Thread Pool (C# Programming Guide)
创建一个列表< thread> myThreadPoolOfTen =新列表< thread>();
如果thread.IsActive为false,则可以使用foreach(myThreadpoolOfTen中的线程线程)进行跟踪.在这种情况下,您可以将任务添加到线程中.
玩得开心
create a List<thread> myThreadPoolOfTen = new List<thread>();
with a foreach (Thread thread in myThreadpoolOfTen) you can follow if thread.IsActive is false. In that case you can add a task to the thread.
Have Fun
这篇关于线程问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文