jjzjj

accumulateAndGet

全部标签

java - AtomicInteger.updateAndGet() 和 AtomicInteger.accumulateAndGet() 之间在功能上有什么区别吗?

有没有AtomicInteger.accumulateAndGet()不能用AtomicInteger.updateAndGet()代替的场景,还是只是为了方便方法引用?这是一个简单的示例,我没有看到任何功能差异:AtomicIntegeri=newAtomicInteger();i.accumulateAndGet(5,Math::max);i.updateAndGet(x->Math.max(x,5));显然,getAndUpdate()和getAndAccumulate()也是如此。 最佳答案 如有疑问,您可以查看implem