C++ thread线程(二)
thread 第二种构造方式:
类函数作为参数:
class Feab
{
public:
explicit Feab(int var):v(var)
{
}
void FeabFunction(int v)
{
cout << v << endl;
}
private:
int v;
};
int main()
{
Feab* m_f = new Feab(10);
thread t1(&Feab::FeabFunction, m_f, 10);
t1.join();
cout << "Hello World!" << endl;
return 0;
}