Linux下一个进程究竟会有多少个线程

最近,在做一个关于聊天服务器的项目,其中遇到了一个问题,那就是一个进程可以产生多少个线程呢?

开始各种想象,会和不同平台,不同系统相关,网上很多大佬说是1024个,也有256个。

与其无端猜测,不如动手测试一下。在Linux32位平台,进行测试。

  1 #include <stdio.h>
  2 #include <unistd.h>
  3 #include <iostream>
  4 #include <stdlib.h>
  5 #include <string.h>
  6 #include <pthread.h>
  7 #include <errno.h>
  8 
  9 using namespace std;
 10 //测试一个进程可以启动多少个线程???
 11 
 12 void *thread_function(void *arg);
 13 
 14 char message[] = "Hello world";
 15 
 16 int main()
 17 {
 18     int res;
 19     pthread_t a_thread;
 20     int i = 0;
 21     
 22     while( 1 )
 23     {
 24         //创建线程
 25         res = pthread_create(&a_thread, NULL, thread_function, (void *)messa    ge);
 26         i++;
 27
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值