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

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

    Platform-independent way (starting from c++11) is:

    #include 
    
    std::this_thread::get_id();
    

提交回复
热议问题