instead of pthread_join, just call pthread_exit(NULL) before returning from the function.