java对象Integer不能引用传递
java对象Integer不能引用传递
/** * The value of the <code>Integer</code>. * * @serial */ private final int value; /** * Constructs a newly allocated <code>Integer</code> object that * represents the specified <code>int</code> value. * * @param value the value to be represented by the * <code>Integer</code> object. */ public Integer(int value) { this.value = value; }
原因:value 使用final 定义
解决:可以使用原子类 AtomicInteger 来实现