【发布时间】:2012-04-27 13:51:33
【问题描述】:
我查看了 ReentrantLock 的 Java API,我可以看到synchronized 关键字没有使用同步。是否在 AbstractQueuedSynchronizer 中的以下方法中(ReentrantLock 在尝试获取锁时引用)同步对象?由于compareAndSwapInt 是本机方法,是否在本机级别/代码进行同步?
protected final boolean compareAndSetState(int expect, int update) {
// See below for intrinsics setup to support this
return unsafe.compareAndSwapInt(this, stateOffset, expect, update);
}
【问题讨论】:
标签: java multithreading synchronization reentrantlock