>>106534094
You don't need refcounting for that either, because typically when your main thread is done processing, it will just wait for the other threads to finish. And after that, you free the resources.
The pthread_join() function waits for the thread specified by thread to terminate. If that thread has already terminated, then pthread_join() returns immediately. The thread specified by
thread must be joinable.