4
例如:在全局范围声明的thread_local变量是否已初始化?
#include <thread>
thread_local int n = 1;
void f()
{
++n; // is n initialized here for each thread or prior to entering f()?
}
int main()
{
std::thread ta(f);
std::thread tb(f);
ta.join();
tb.join();
}
它仍然没有完全从here明确为n初始化时。
线程初始化时。 –
对于每个线程(线程)初始化时。 –
相关:http://stackoverflow.com/questions/24253584/when-is-a-thread-local-global-variable-initialized –