0

在研究jdk源代码(jdk 1.8.0_111)时,我发现一段奇怪的代码如下:

public class AtmicBoolean implements Serializable {

    private static final long serialVersionUID = 4654671469794556979L;
    private static final Unsafe unsafe = ;
    private static final long valueOffset;
    private volatile int value;

    static {
        try {
            valueOffset = unsafe.objectFieldOffset(AtomicBoolean.class.getDeclaredField("value"));
        } catch (Exception localException) {
            throw new Error(localException);
        }
    }
  // .... other codes
}

问题:不安全变量在哪里设置?

4

0 回答 0