What is the difference between C++11 functions get_id()
and native_handle()
?
In the test program I created they return the same int
value for their threads so I have no idea what the difference is.
I'm using GCC 4.8.1 on Windows.
From this reference:
get_id
returns the id of the thread
and
native_handle
returns the underlying implementation-defined thread handle
The thread identifier as returned by get_id
should actually be a class (std::thread::id
) and not a number or other platform specific handle.
The native_handle
function returns just what its name implies, a native handle that can be used by the underlying operating systems thread functions. On Windows this is typically a HANDLE
as returned by CreateThread
, on POSIX platforms it's typically a pthread_t
as initialized by pthread_create
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With