AtomicIntegerArray、AtomicLongArray、AtomicReferenceArray
package com.xdclass.atomic.demo2; import java.util.concurrent.atomic.AtomicIntegerArray; public class AtomicIntegerArrayDemo { public static void main(String[] args) { int[] arr = new int[]{3,2}; AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(arr); int i = atomicIntegerArray.addAndGet(1, 2); System.out.println(i); //自定义执行函数 atomicIntegerArray.accumulateAndGet(0, 2, ((left, right) -> left > right ? left :right )); } }