当前位置: 技术问答>linux和unix
linux最多能同时运行几个线程?
来源: 互联网 发布时间:2016-02-19
本文导语: 我写了程序如下: 结果创建到第306个线程时就报如下错误: can't create thread 306: Cannot allocate memory can't create thread 307: Cannot allocate memory 谁能帮忙解释下为什么吗? 难道同时只能运行305个线程么? #include #include #i...
我写了程序如下:
结果创建到第306个线程时就报如下错误:
can't create thread 306: Cannot allocate memory
can't create thread 307: Cannot allocate memory
谁能帮忙解释下为什么吗?
难道同时只能运行305个线程么?
#include
#include
#include
pthread_t ntid;
void *
thr_fn(void *arg)
{
pthread_detach(pthread_self());
sleep(50000);
}
#define MAXTHREAD 600
int
main(void)
{
int err;
int i;
for (i = 0; i
结果创建到第306个线程时就报如下错误:
can't create thread 306: Cannot allocate memory
can't create thread 307: Cannot allocate memory
谁能帮忙解释下为什么吗?
难道同时只能运行305个线程么?
#include
#include
#include
pthread_t ntid;
void *
thr_fn(void *arg)
{
pthread_detach(pthread_self());
sleep(50000);
}
#define MAXTHREAD 600
int
main(void)
{
int err;
int i;
for (i = 0; i