1.

What Do You Mean By An Atomic Operation?

Answer»

In programming, an atomic operation is one that effectively happens all at once. An atomic operation cannot stop in the MIDDLE: it either happens completely, or it doesn’t happen at all. No SIDE effects of an atomic operation are visible until the action is complete.
In Java,

  • Reads and writes are atomic for reference variables and for most primitive variables (all types except long and double).
  • Reads and writes are atomic for all variables DECLARED volatile (including long and double variables).
  • all operations of java.concurrent.Atomic* classes

Atomic actions cannot be INTERLEAVED, so they can be used without fear of thread interference. However, this does not eliminate all need to synchronize atomic actions, because memory consistency errors are still possible.

In programming, an atomic operation is one that effectively happens all at once. An atomic operation cannot stop in the middle: it either happens completely, or it doesn’t happen at all. No side effects of an atomic operation are visible until the action is complete.
In Java,

Atomic actions cannot be interleaved, so they can be used without fear of thread interference. However, this does not eliminate all need to synchronize atomic actions, because memory consistency errors are still possible.



Discussion

No Comment Found