一、数据竞争的产生

在下面例子中:

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;
}
View Code

相关文章:

  • 2021-07-29
  • 2022-12-23
  • 2021-11-07
猜你喜欢
  • 2022-12-23
  • 2021-10-01
  • 2021-08-27
  • 2021-08-01
  • 2022-12-23
  • 2021-05-29
  • 2021-07-25
相关资源
相似解决方案