In C is “i+=1;” atomic?

后端 未结 12 2090
天命终不由人
天命终不由人 2020-12-28 12:58

In C, is i+=1; atomic?

12条回答
  •  温柔的废话
    2020-12-28 13:31

    Just put a mutex or a semaphore around it. Of course it is not atomic and you can make a test program with 50 or so threads accessing the same variable and incrementing it, to check it for yourself

提交回复
热议问题