make a choice pthread_join or pthread_detach

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.

Advertisements
This entry was posted in Programming and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s