You can also pass PTHREAD_CREATE_DETACHED as part of thread attribute when you create it. This way, you dont have to worry about joining the thread later on. Something like this:
pthread_t;
int status;
pthread_attr_t attr;
status = pthread_attr_init(&attr);
if (status != 0) {
fprintf(stderr, "pthread_attr_init() failed [status: %d]\n", status);
return 0;
}
status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (status != 0) {
fprintf(stderr, "pthread_attr_setdetachstate() failed [status: %d]\n", status);
return 0;
}
status = pthread_create(&t, &attr, myRoutine, 0);