传统的C++(C++11之前)中并没有引入线程这个概念
C++11引入了头文件<thread>,提供了 管理线程 保护共享数据 线程间同步操作 原子操作等
<thread>
join() detach() get_id() yield() sleep_for() sleep_until()
#include <thread>
int main()
{
std::thread t1;
std::cout << t1.get_id() << std::endl;
return 0;}
//线程函数为函数指针
std::thread t1(ThreadFunc, 10);//线程函数为lambda表达式
std::thread t2([] {std::cout << "Thread2" << std::endl; });//线程函数为函数对象
TF tf;
thread t3(tf);t1.join();
t2.join();
t3.join();
std::cout << "Main thread" << std::endl;
return 0;
<mutex>
<atomic>
<condition_variable>
<future>
标签:11,std,join,thread,C++,线程,多线程 From: https://www.cnblogs.com/k5bg/p/17491754.html