std::this_thread:: get_id
From cppreference.net
C++
Concurrency support library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
헤더 파일에 정의됨
<thread>
|
||
|
std::
thread
::
id
get_id
(
)
noexcept
;
|
(C++11부터) | |
현재 스레드의 id 를 반환합니다.
목차 |
매개변수
(없음)
반환값
id 현재 스레드의 식별자.
예제
이 코드 실행
#include <chrono> #include <iostream> #include <syncstream> #include <thread> using namespace std::chrono_literals; void foo() { std::thread::id this_id = std::this_thread::get_id(); std::osyncstream(std::cout) << "thread " << this_id << " sleeping...\n"; std::this_thread::sleep_for(500ms); } int main() { std::jthread t1{foo}; std::jthread t2{foo}; }
가능한 출력:
thread 140113018054400 sleeping... thread 140113009661696 sleeping...
참고 항목
|
스레드의
id
를 반환합니다
(
std::thread
의 public 멤버 함수)
|
|
|
C 문서
for
thrd_current
|
|