std::thread is a C++11 standard library class which represents a single thread of execution. Threads allow multiple functions to execute concurrently.
std::thread
is a C++11 standard library type which creates a new thread and runs a function (or other callable object) in that new thread.
Include the <thread>
header to use std::thread
.
C++20 added std::jthread
which automatically .join()
s the thread on destruction instead of std::terminate()
ing, a generally preferable behavior.