5,337
edits
(→Thread) |
|||
Line 176: | Line 176: | ||
===Thread=== | ===Thread=== | ||
<code>#include <thread></code><br> | <code>#include <thread></code><br> | ||
[https://en.cppreference.com/w/cpp/thread/thread std::thread reference]<br> | |||
Basic Usage: | |||
<syntaxhighlight lang="C++"> | |||
std::thread my_thread = new std::thread(thread_function); | |||
// or | |||
std::thread my_thread = new std::thread(&Class::method, this)); | |||
// Wait for thread to finish | |||
my_thread.join(); | |||
// get id of thread | |||
std::thread::id my_id = my_thread.get_id(); | |||
// get id of this thread | |||
std::thread::id my_id = std::this_thread::get_id(); | |||
</syntaxhighlight> | |||
==== Sleep ==== | ==== Sleep ==== | ||
<syntaxhighlight lang="C++"> | <syntaxhighlight lang="C++"> |