测试我的笔记本能承受多少个线程创建

/***
*    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

测试我的笔记本能承受多少个线程创建

上一篇:Spring事务的传播特性


下一篇:C语言内存对齐