How understand the result of incrementing and printing a global variable by two threads?

前端 未结 0 1148
[愿得一人]
[愿得一人] 2020-12-17 06:03

In my main I have two threads running the following function:

int i = 0;    

void foo()
{
   ++i;
   printf("%d", i);
}

I ran it 1

相关标签:
回答
  • 消灭零回复
提交回复
热议问题