c语言多线程问题,快速创建多个线程!

for(int i=10;i>0;i--)
pthread_create(&pid,NULL,doit,NULL);

怎么创建出来的线程ID是重复的啊?应该怎么处理快速创建线程的时候,线程ID会复用?

你用了一个pid,当然只能获得一个id了,改为:

 pthread pid[10];
 for(int i=10;i>0;i--)
pthread_create(&pid[i],NULL,doit,NULL);

pthread pid[11];