Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why and when to use AtomicIntegerFieldUpdater?

Why and when should one use these classes?

  • AtomicIntegerFieldUpdater
  • AtomicMarkableReference
  • AtomicReference

Kindly explain using a real life scenario!

like image 455
Gaurav Seth Avatar asked Jun 17 '13 17:06

Gaurav Seth


1 Answers

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.

like image 79
Eun Woo Song Avatar answered Oct 13 '22 17:10

Eun Woo Song