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

后端 未结 11 834
忘了有多久
忘了有多久 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:41

    pid_t tid = syscall(SYS_gettid);
    

    Linux provides such system call to allow you get id of a thread.

提交回复
热议问题