/*** * test how many threads can be created in x86 32 system * * ubuntu 13.0 * * *************************************************************/ #include <stdio.h> #include <pthread.h> static void test(void *arg); int main() { pthread_t p; pthread_attr_t pattr; pthread_attr_init(&pattr); pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_DETACHED); int count =0; while(pthread_create(&p, &pattr, test, NULL) == 0) { count++; } printf("only %d threads can be created\n", count); return 0; } static void test(void *arg) { while(1) { //do nothing } }
结果:
only 382 threads can be created
测试我的笔记本能承受多少个线程创建,布布扣,bubuko.com
原文:http://www.cnblogs.com/unixshell/p/3819043.html