how to get thread id of a pthread in linux c program?

后端 未结 11 815
忘了有多久
忘了有多久 2020-12-02 07:05

In linux c program, how to print thread id of a thread created by pthread library?
for ex: we can get pid of a process by getpid()

11条回答
  •  甜味超标
    2020-12-02 07:35

    You can use pthread_self()

    The parent gets to know the thread id after the pthread_create() is executed sucessfully, but while executing the thread if we want to access the thread id we have to use the function pthread_self().

提交回复
热议问题