compile: gcc -o thread thread.c
-lpthread
from this example,I know redhat7.3 - 8.0 can only
create 256 thread(include main thread and the thread of create
subthread)
#include <pthread.h>
#include <errno.h> #include <strings.h> #include <unistd.h> #include <signal.h> void *mysleep(int
id)
{ printf("threadid = %d pid = %d ppid = %d\n", id, getpid(), getppid()); sleep(20); } void
main(void)
{ int l_i = 0; pthread_t id[10000];
signal(SIGCLD, SIG_IGN);
printf("pid = %d\n", getpid()); while(l_i
< 2000)
{
int ret = 0; ret = pthread_create(&(id[l_i]), NULL, (void *)mysleep, l_i); if (ret != 0) { printf("errno = %d(%s) l_i = %d\n", errno, strerror(errno), l_i); exit(1); } l_i++; } sleep(100); }
|
- FAQ Cullip, Lee
- FAQ 史绪良
- Re: FAQ David Busby
- Re: how create many thread (over 256... 史绪良
- Re: how create many thread (over... Willem Brown
- Re: how create many thread ... Willem Brown
- where is source code of libpthre... long Smith
- where is source code of lib... long Smith
- Re: how create many thread (over... fred smith
- Re: how create many thread (over... David Busby
- Re: FAQ Andrea Dell'Amico