I presumed that a pthread_t
remains constant - for a given thread - for its entire life, but my experimentation seems to be proving this assumption false. If the id for a given thread does not remain constant across its life, how can I store a pthread_t
so another thread can use pthread_join
to block until the thread is finished?
For other reasons it would be useful for me to know how to get a unique identifier for a thread that I can convert back and forth to a pthread_t
. Is there a way of doing this?
There is lots of great information out there, but I've had a hard time pinning down useful answers for these questions. I'd appreciate any help/advice I can get!
edit: Also, i'm not sure why, but everything seems to work as expected when adding sleep(1) and sleeping for 1sec at the front of every new thread (within the thread's function). This is probably grasping as straws, but could pthread_t
values change momentarily during the start of a new thread or something??