代码
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections; using System.Threading;
namespace test
{
class Program
{ static void Main(string[] args)
{ for (int i = 0; ; i++)
{ try
{
ceshi ch = new ceshi();
//ch.dispose();
// th.Abort();
// Thread.Sleep(1000);
Console.WriteLine(">>"+i);
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
break;
} }
Console.Read();
}
}
class ceshi
{
public Thread th;
public ceshi()
{
th = new Thread(f);
th.Start();
}
void f()
{
int k = 0; while (true)
{
k++;
Thread.Sleep(1000);
//if (k == 10)
//{
// break;
//}
}
}
public void dispose()
{
th.Abort();
}
~ceshi()
{
th.Abort();
}
}
}
当跑到第1862(不同机器不一样) 时候,就报System.OutOfMemoryException 错误
根本不是电脑内存不够,程序才吃到50M 左右 我电脑4G内存
这到底怎么回事啊
怎么解决这个问题 求高手相助啊
因为我的程序需要启动很多线程
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections; using System.Threading;
namespace test
{
class Program
{ static void Main(string[] args)
{ for (int i = 0; ; i++)
{ try
{
ceshi ch = new ceshi();
//ch.dispose();
// th.Abort();
// Thread.Sleep(1000);
Console.WriteLine(">>"+i);
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
break;
} }
Console.Read();
}
}
class ceshi
{
public Thread th;
public ceshi()
{
th = new Thread(f);
th.Start();
}
void f()
{
int k = 0; while (true)
{
k++;
Thread.Sleep(1000);
//if (k == 10)
//{
// break;
//}
}
}
public void dispose()
{
th.Abort();
}
~ceshi()
{
th.Abort();
}
}
}
当跑到第1862(不同机器不一样) 时候,就报System.OutOfMemoryException 错误
根本不是电脑内存不够,程序才吃到50M 左右 我电脑4G内存
这到底怎么回事啊
怎么解决这个问题 求高手相助啊
因为我的程序需要启动很多线程
解决方案 »
- Page.ClientScript.RegisterStartupScript注册脚本后,重复运行问题
- 求助,关于项止施实时要求SQL2000 在远程无法访问,只能在服务器上访问!100分求解高手飞啊!
- 怎么对textBox所输入的内容进行限制?
- 求助~~~~~~~~~~~~~~~~~~~~~~对于单引号被替换成两个单引号后就可以了吗???
- 如何从网上下载一个文件的HTML代码
- [版务]处理12345zds倒分 及 论坛是否倒分的界定
- 附件上传并保存到数据库的问题
- 从别的电脑上的excel导数据到服务器的access,怎么写asp代码啊>
- 关于用户控件的问题。。。急 在线等
- 关于ASP.NET在线编译的问题
- 我想实现省份县无刷新三级联动,脚本提示AjaxPCA(这是个自定义的命名空间名称)未定义请各位指教
- 急!!将Access数据库中读取数据显示到web页中(C#)
结果现在用户一多 就出现 System.OutOfMemoryException 这个错误
不知道这什么意思
也从没听说 线程数有限制啊没人知道吗