一、数据竞争的产生
在下面例子中:
void function_1() { for (int i = 0; i < 100; i++) { std::cout << "from function 1:" << i << std::endl; } } int main() { std::thread t(function_1); for (int i = 0; i < 100; i++) { std::cout << "from function main:"<<i<<std::endl; } t.join(); std::getchar(); return 0; }