If main() finishes before the threads it has created, and exits with pthread_exit(), the other threads will continue to execute. Otherwise, they will be automatically terminated when main() finishes.
https://computing.llnl.gov/tutorials/pthreads/
Exit main function by calling pthread_exit()