有没有一种方法可以使用“new”关键字在堆上初始化std::thread
?
最佳答案
不要使用new,请使用make_unique
这句话:
#include<thread>
#include<memory>
bool fun1()
{
return true;
}
int main() {
auto thread1 = std::make_unique<std::thread>( fun1 );
thread1->join();
}
关于c++ - 如何在堆上初始化线程? (使用 “new”关键字),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59081712/