Why and when should one use these classes?
AtomicIntegerFieldUpdater
AtomicMarkableReference
AtomicReference
Kindly explain using a real life scenario!
AtomicIntegerFieldUpdater
can be used if said field needs to be used as just regular volatile field (without declaring them as AtomicXXX
class) but needs atomic operations occasionally. Also, if you are creating a lot of objects and you don't want to create a lot of AtomicXXX
objects, you can create a static AtomicIntegerFieldUpdater
object and let it be shared between all the objects. This article explains more in detail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With