Hi everyone, just wondering if anyone knows if any variable++ would be classed as 1 atomic action? Thanks guys

In general, no.

Thanks Dogtree for replying, I had this question in an exam, true or false, I don't know anything about it though, would you be able to explain why it is false, that would be great

By its definition, the postfix increment operator has to use temporary storage so that it can return the pre-incremented value. You can think of it like this:

operator++
  temp = self;
  self = self + 1;
  return temp;

Optimizations can make it close to atomic for all cases of built-in types, or atomic for some cases of some built-in types, but in the general case, it's not gonna happen. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.