YC Yc.W home Systems · C++ · AI Infrastructure
C & C++ · Note

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

Explore all C & C++ notes →

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();

← Previous C++-#pragma once