There's more...

As mentioned in the introduction, there are other atomic classes in Java. AtomicBoolean, AtomicInteger, and AtomicReference are other examples of atomic classes.

The LongAdder class provides other interesting methods as follows:

  • add(): To increment the value of the internal counter by the value specified as a parameter
  • decrement(): To decrement the internal counter by one
  • reset(): To return the internal value to zero

You can also use the DoubleAdder class that is similar to LongAdder, but it doesn't have the increment() and decrement() methods and the internal counter is a double value.

You can also use the LongAccumulator class that is similar to DoubleAccumulator but with an internal long counter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.139.224