JUC-关于CopyOnWriteArrayList的疑问


transient final ReentrantLock lock = new ReentrantLock();
.....................
.....................


private static final Unsafe unsafe = Unsafe.getUnsafe();
private static final long lockOffset;
static {
try {
lockOffset = unsafe.objectFieldOffset
(CopyOnWriteArrayList.class.getDeclaredField("lock"));
} catch (Exception ex) { throw new Error(ex); }
}
private void resetLock() {
unsafe.putObjectVolatile(this, lockOffset, new ReentrantLock());
}

[list]

[*] 在反序列化之后如何重设锁的呢?

[/list]

    原文作者:JUC
    原文地址: https://blog.csdn.net/iteye_6287/article/details/82411757
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞