Is there any functional difference between AtomicInteger.updateAndGet() and AtomicInteger.accumulateAndGet()?

Viewed 7058

Is there any scenario in which AtomicInteger.accumulateAndGet() can't be replaced with AtomicInteger.updateAndGet(), or is it just a convenience for method references?

Here's a simple example where I don't see any functional difference:

AtomicInteger i = new AtomicInteger();
i.accumulateAndGet(5, Math::max);
i.updateAndGet(x -> Math.max(x, 5));

Obviously, the same goes for getAndUpdate() and getAndAccumulate().

2 Answers
Related