#include <iostream>
#include <thread> //c++11中 thread的头文件 C++11中的很多函数都放到了std库里面
void testThread()
{
std::cout << "this is funciton: " << __func__ << std::endl;
}
int main()
{
std::cout << "first function: "<<__func__ << std::endl;
std::thread th1(testThread);
th1.join();
std::cout << __func__ << " end" << std::endl;
}
本文展示了如何使用C++11标准库中的线程功能来创建并运行一个简单的线程。通过main函数和testThread函数的实例,介绍了线程的创建、执行和join方法的使用。
1444

被折叠的 条评论
为什么被折叠?



