Depends if you want to get some sort of status code or return value from the thread. If the thread doesn’t need to signal any errors (or it signals errors in some other way than the return code), then using detach is preferable since it (slightly) reduces overhead. If you want to get the return code from the thread, then you need to use pthread_join. pthread_join is also useful for making sure than another thread has finished it’s work.
Advertisement