用一个 test.c 程序测试:#include #include #include #include #include #define MAX_TEST_THREAD 3000void * handle(void *data){ while(1) sleep(1);}int main(){ int i, n, r; pthread_t pid; printf("Now try to create %d threads.n",MAX_TEST_THREAD); for(i=0, n=0; i复制代码 [oracle@localhost]$ ./test Now try to create 3000 threads. pthread_create error: Resource temporarily unavailable 885 threads have been created! // oracle用户创建线程有限制,不能创建3000个线程。
[oracle@localhost]$ su Password: [root@localhost]# ./test Now try to create 3000 threads. 3000 threads have been created! // root用户能创建3000个线程。 [root@localhost]#