答案
普通函数、仿函数、lambda 表达式
栗子
#include <iostream>
#include <thread>
class CTest
{
public:
// 仿函数。
void operator()()
{
std::cout << " () " << std::endl;
return;
}
};
// 普通函数。
void func()
{
std::cout << " func " << std::endl;
return;
}
int main()
{
CTest test;
std::thread thread_1(func);
std::thread thread_2(test);
// lambda 表达式。
auto other = []{
std::cout << " other " << std::endl;
return;
};
std::thread thread_3(other);
thread_1.join();
thread_2.join();
thread_3.join();
return 0;
}
结果(不一定)
func ()
other
(SAW:Game Over!)