stackover流程异常 [英] stackover flow exception
本文介绍了stackover流程异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我有一个代码:
Hello,
I have a code:
public class threading
{
Thread[] t;
Thread monitor_q;
ReadPackets rdpck;
Networking net;
general gen;
public threading()
{
t = new Thread[250]; /////starts throwing stackoverflow exception from here onwards
net = new Networking();
gen = new general();
monitor_q = new Thread(monitor);
net.instantiate_5070();
start_monitor_queue();
}
public void start_monitor_queue()
{
monitor_q.IsBackground = true;
monitor_q.Start();
}
}
请指教,
谢谢,
- Rahul
Please advise,
Thanks,
- Rahul
推荐答案
建议您使用尽可能少的线程,从而最大限度地减少使用 - 系统资源和提高性能。所以你试图创建一个包含250个线程的数组,而你的系统没有资源。
It is recommended that you use as few threads as possible, thereby minimizing the use of operating-system resources and improving performance. So your trying to create an array of 250 threads and your system do not have resource for them.
250个线程太多了,除非你有一个超过100个处理器主板,我怀疑。
此外,你可以使用一个ThreadPool
对象,目标是管理几个一起运行的线程。以下是一些链接:
ThreadPool类 [ ^ ]
如何:使用线程池(C#和Visual基本) [ ^ ]
祝你好运。
250 threads are way too much, except if you have a more-than-100-processors motherboard, which I doubt.
Moreover, there is aThreadPool
object that you can use which aims at the management of several threads running alltogether. Here are some links:
ThreadPool Class[^]
How to: Use a Thread Pool (C# and Visual Basic)[^]
Good luck.
这篇关于stackover流程异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文