Re: pthread_join
Re: pthread_join
- Subject: Re: pthread_join
- From: Matt Watson <email@hidden>
- Date: Thu, 9 Sep 2004 13:10:43 -0700
Would this be better (performance wise) then using an attached thread?
You probably wouldn't notice the performance difference, since they use
the same underlying mechanism. You'd do something like this at the end
of your thread's body routine:
pthread_mutex_lock(&mMutex);
gThread_B_Finished = true;
pthread_mutex_unlock(&mMutex);
pthread_cond_signal(&mCondVar);
then in your "waiting" routine, do:
pthread_mutex_lock(& mMutex);
while (gThread_B_Finished == false)
pthread_cond_wait(& mCondVar, & mMutex);
pthread_mutex_unlock(& mMutex);
And you'll want to add error checking appropriate for your application
to the above code, of course.
matt.
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.