Click to See Complete Forum and Search --> : Creating and joining pthreads


vr84
July 27th, 2007, 10:12 PM
If a thread is created with the PTHREAD_CREATE_JOINABLE attribute it does not execute until you call pthread_join. Is this correct?

NoHero
July 28th, 2007, 03:40 PM
No. You call pthread_join to wait for a thread to terminate. If the thread is not created with PTHREAD_CREATE_JOINABLE neither the thread status nor its exit status are preserved after thread termination for a pthread_join call on the thread. Normally pthread_join will return EINVAL for a thread that has terminated and does not have the PTHREAD_CREATE_JOINABLE flag.

Further reading: http://www.cs.cf.ac.uk/Dave/C/node30.html

vr84
July 28th, 2007, 06:19 PM
Thanks for clearing that up and posting that link, I understand it now.

exterminator
August 22nd, 2007, 02:06 PM
The default for a pthread is joinable state. pthread_join call on detached thread is an error as mentioned by NoHero.