/** * 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 来实现
时间: 2024-10-25 06:22:43