954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Using/Omitting pthread_join()

When programming with pthreads, you pass the thread a function to run when you create it. When this function is done, is the thread cleaned up automatically? Is it necessary to put pthread_join() in the calling function somewhere? Is pthread_join only useful when you want towait for a thread to finish?

nanodano
Junior Poster in Training
78 posts since Feb 2005
Reputation Points: 36
Solved Threads: 2
 

You should always kill the threads as the finish up the work. So you need to join the thread in order to stop it. Threads can provide significant overhead if left to run wild so make sure you clean up all threads in your exit handler.

mcldev
Light Poster
31 posts since Feb 2005
Reputation Points: 10
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You