1

first argument of pthread_create is pthread_t (which is typedef'ed to long), which I understand is thread ID.

Does it set this value to zero when thread finishes execution? I would like to use it to check if the thread is running

Dmitry
  • 2,837
  • 1
  • 30
  • 48

1 Answers1

0

No, the pthread_t isn't changed by the pthread library once it's initialized. Pass the pthread_t object to pthread_join() to wait until the thread is finished. If you want to determine without blocking, you can have the thread cooperate by setting an indicator for it's state in some shared object.

Michael Burr
  • 333,147
  • 50
  • 533
  • 760