//non-detached threads do not use the Join function example:#include <stdlib.h>#include<pthread.h>#include<stdio.h>#include<sched.h>#include<errno.h>void*consumer (void*p) { StaticA=0 ; A++; printf ("<<<<<<<<<<<<<<<<<<<<< (%u),%d\n", (unsigned) pthread_self (), a); Pthread_exit (NULL);}intMainintargcChar*argv[]) {pthread_t t1,t2,t3; intret; Do{ret=pthread_create (&t1,null,consumer,null); if(ret!=0) {printf ("Create failed,%d\n", ret); Exit (1); } } while(1); Sleep (1); return 0 ;}/*After you create 350 or so threads, you can no longer create threads, and the thread thread numbers you have created are different. <<<<<<<<<<<<<<<<<<<<< (33799056),362<<< <<<<<<<<<<<<<<<<<< (25406352),363<<<<<< <<<<<<<<<<<<<<< (17013648),364<<<<<<<<< <<<<<<<<<<<< (8620944), 365create failed,12 not this program output, but can explain the problem*/
Non-detached threads do not use the Join function example: