src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
Print this page
*** 213,223 ****
*
* @since 1.5
* @author Doug Lea
*
*/
! public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializable {
private static final long serialVersionUID = -6992448646407690164L;
/** Inner class providing readlock */
private final ReentrantReadWriteLock.ReadLock readerLock;
/** Inner class providing writelock */
private final ReentrantReadWriteLock.WriteLock writerLock;
--- 213,224 ----
*
* @since 1.5
* @author Doug Lea
*
*/
! public class ReentrantReadWriteLock
! implements ReadWriteLock, java.io.Serializable {
private static final long serialVersionUID = -6992448646407690164L;
/** Inner class providing readlock */
private final ReentrantReadWriteLock.ReadLock readerLock;
/** Inner class providing writelock */
private final ReentrantReadWriteLock.WriteLock writerLock;
*** 249,259 ****
/**
* Synchronization implementation for ReentrantReadWriteLock.
* Subclassed into fair and nonfair versions.
*/
! static abstract class Sync extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = 6317671515068378041L;
/*
* Read vs write count extraction constants and functions.
* Lock state is logically divided into two unsigned shorts:
--- 250,260 ----
/**
* Synchronization implementation for ReentrantReadWriteLock.
* Subclassed into fair and nonfair versions.
*/
! abstract static class Sync extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = 6317671515068378041L;
/*
* Read vs write count extraction constants and functions.
* Lock state is logically divided into two unsigned shorts:
*** 616,626 ****
return new ConditionObject();
}
final Thread getOwner() {
// Must read state before owner to ensure memory consistency
! return ((exclusiveCount(getState()) == 0)?
null :
getExclusiveOwnerThread());
}
final int getReadLockCount() {
--- 617,627 ----
return new ConditionObject();
}
final Thread getOwner() {
// Must read state before owner to ensure memory consistency
! return ((exclusiveCount(getState()) == 0) ?
null :
getExclusiveOwnerThread());
}
final int getReadLockCount() {
*** 667,677 ****
}
/**
* Nonfair version of Sync
*/
! final static class NonfairSync extends Sync {
private static final long serialVersionUID = -8159625535654395037L;
final boolean writerShouldBlock() {
return false; // writers can always barge
}
final boolean readerShouldBlock() {
--- 668,678 ----
}
/**
* Nonfair version of Sync
*/
! static final class NonfairSync extends Sync {
private static final long serialVersionUID = -8159625535654395037L;
final boolean writerShouldBlock() {
return false; // writers can always barge
}
final boolean readerShouldBlock() {
*** 687,697 ****
}
/**
* Fair version of Sync
*/
! final static class FairSync extends Sync {
private static final long serialVersionUID = -2274990926593161451L;
final boolean writerShouldBlock() {
return hasQueuedPredecessors();
}
final boolean readerShouldBlock() {
--- 688,698 ----
}
/**
* Fair version of Sync
*/
! static final class FairSync extends Sync {
private static final long serialVersionUID = -2274990926593161451L;
final boolean writerShouldBlock() {
return hasQueuedPredecessors();
}
final boolean readerShouldBlock() {
*** 865,875 ****
* @return {@code true} if the read lock was acquired
* @throws InterruptedException if the current thread is interrupted
* @throws NullPointerException if the time unit is null
*
*/
! public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout));
}
/**
* Attempts to release this lock.
--- 866,877 ----
* @return {@code true} if the read lock was acquired
* @throws InterruptedException if the current thread is interrupted
* @throws NullPointerException if the time unit is null
*
*/
! public boolean tryLock(long timeout, TimeUnit unit)
! throws InterruptedException {
return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout));
}
/**
* Attempts to release this lock.
*** 1106,1116 ****
*
* @throws InterruptedException if the current thread is interrupted
* @throws NullPointerException if the time unit is null
*
*/
! public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
return sync.tryAcquireNanos(1, unit.toNanos(timeout));
}
/**
* Attempts to release this lock.
--- 1108,1119 ----
*
* @throws InterruptedException if the current thread is interrupted
* @throws NullPointerException if the time unit is null
*
*/
! public boolean tryLock(long timeout, TimeUnit unit)
! throws InterruptedException {
return sync.tryAcquireNanos(1, unit.toNanos(timeout));
}
/**
* Attempts to release this lock.