【发布时间】:2020-04-16 03:44:55
【问题描述】:
是否允许在另一个线程中创建的std::thread 对象上调用join(),前提是该对象在线程之间正确同步?
例如:
void cleanup(std::thread t)
{
t.join();
}
int main()
{
std::thread t{[] { /* something */ }};
std::thread c{cleanup, std::move(t)};
c.join();
}
【问题讨论】:
标签: c++ multithreading c++11 thread-safety