Re: PR_CreateThread -> PR_DestroyThread

Benjamin Smedberg <[email protected]> Thu, 15 Apr 2010 14:12:53 -0400
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
On 4/15/10 1:56 PM, Mike Moening wrote:
> If I use PR_CreateThread() and get back a PRThread*
> How and where it that pointer deleted once that thread dies.
> Seems we are missing an API:  PR_DestroyThread()

You should never "destroy" a thread, because it may be holding a lock or 
doing some other synchronized activity. Instead you should signal the thread 
to exit (using a monitor or other thread signalling device). The main thread 
then waits for the thread to exit by calling PR_JoinThread. The thread exits 
by returning from the thread function.

--BDS