返回信息流一个进程能同时容纳多少个线程?系统限制还是编译器的限制?这个限制能改么?
g++ 下编译运行,似乎是300多点
[quote]
#include <pthread.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int i = 0;
void *doit(void *vptr)
{
cout << i++ << ": " << pthread_self() << endl; //打印目前线程的编号
sleep(1); //假设每个线程都要1秒的处理时间
return NULL;
}
int main()
{
while(1)
{
pthread_t pid1;
pthread_create(&pid1, NULL, &doit, NULL);
pthread_detach(pid1);
}
}
[/quote]
这是一条镜像帖。来源:北邮人论坛 / cpp / #16370同步于 2008/11/20
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
多线程的极限问题
ATV
2008/11/20镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复