64,685
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <thread>
class A
{
public:
A() : _thread (&A::test, this) { }
~A()
{
_thread.join();
}
void test()
{
for(int i = 0; i < 100; ++i)
{
std::cout << i << std::endl;
}
}
std::thread _thread;
};
int main()
{
A a;
return 0;
}