C++-std::this_thread::get_id()-获取线程id

发布时间 2023-04-29 18:47:36作者: Theseus‘Ship

C++-std::this_thread::get_id()-获取线程id

std::this_thread::get_id()

头文件:<thread>
函数:std::this_thread::get_id()
用例:std::thread::id thread_id = std::this_thread::get_id();

std::thread对象的成员函数get_id()

头文件:<thread>
函数:std::thread::id get_id()
用例:通过调用std::thread对象的成员函数get_id()来直接获取

#include <thread>

std::thread t;
t.get_id();