src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
Print this page
@@ -213,11 +213,12 @@
*
* @since 1.5
* @author Doug Lea
*
*/
-public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializable {
+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,11 +250,11 @@
/**
* Synchronization implementation for ReentrantReadWriteLock.
* Subclassed into fair and nonfair versions.
*/
- static abstract class Sync extends AbstractQueuedSynchronizer {
+ 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,11 +617,11 @@
return new ConditionObject();
}
final Thread getOwner() {
// Must read state before owner to ensure memory consistency
- return ((exclusiveCount(getState()) == 0)?
+ return ((exclusiveCount(getState()) == 0) ?
null :
getExclusiveOwnerThread());
}
final int getReadLockCount() {
@@ -667,11 +668,11 @@
}
/**
* Nonfair version of Sync
*/
- final static class NonfairSync extends 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,11 +688,11 @@
}
/**
* Fair version of Sync
*/
- final static class FairSync extends Sync {
+ static final class FairSync extends Sync {
private static final long serialVersionUID = -2274990926593161451L;
final boolean writerShouldBlock() {
return hasQueuedPredecessors();
}
final boolean readerShouldBlock() {
@@ -865,11 +866,12 @@
* @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 {
+ public boolean tryLock(long timeout, TimeUnit unit)
+ throws InterruptedException {
return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout));
}
/**
* Attempts to release this lock.
@@ -1106,11 +1108,12 @@
*
* @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 {
+ public boolean tryLock(long timeout, TimeUnit unit)
+ throws InterruptedException {
return sync.tryAcquireNanos(1, unit.toNanos(timeout));
}
/**
* Attempts to release this lock.