下面列出了java.util.concurrent.locks.StampedLock#asReadLock() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
static Reader interruptibleReaderView(final StampedLock sl,
final long timeout,
final TimeUnit unit,
final Phaser gate) {
return new Reader("InterruptibleReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
try {
if (timeout < 0)
rl.lockInterruptibly();
else
rl.tryLock(timeout, unit);
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} catch (Throwable x) { thrown(x);
} finally { if (stamp() != 0L) rl.unlock(); } }};
}
static Reader interruptibleReaderView(final StampedLock sl,
final long timeout,
final TimeUnit unit,
final Phaser gate) {
return new Reader("InterruptibleReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
try {
if (timeout < 0)
rl.lockInterruptibly();
else
rl.tryLock(timeout, unit);
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} catch (Throwable x) { thrown(x);
} finally { if (stamp() != 0L) rl.unlock(); } }};
}
static Reader interruptibleReaderView(final StampedLock sl,
final long timeout,
final TimeUnit unit,
final Phaser gate) {
return new Reader("InterruptibleReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
try {
if (timeout < 0)
rl.lockInterruptibly();
else
rl.tryLock(timeout, unit);
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} catch (Throwable x) { thrown(x);
} finally { if (stamp() != 0L) rl.unlock(); } }};
}
static Reader interruptibleReaderView(final StampedLock sl,
final long timeout,
final TimeUnit unit,
final Phaser gate) {
return new Reader("InterruptibleReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
try {
if (timeout < 0)
rl.lockInterruptibly();
else
rl.tryLock(timeout, unit);
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} catch (Throwable x) { thrown(x);
} finally { if (stamp() != 0L) rl.unlock(); } }};
}
static Reader interruptibleReaderView(final StampedLock sl,
final long timeout,
final TimeUnit unit,
final Phaser gate) {
return new Reader("InterruptibleReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
try {
if (timeout < 0)
rl.lockInterruptibly();
else
rl.tryLock(timeout, unit);
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} catch (Throwable x) { thrown(x);
} finally { if (stamp() != 0L) rl.unlock(); } }};
}
static Reader interruptibleReaderView(final StampedLock sl,
final long timeout,
final TimeUnit unit,
final Phaser gate) {
return new Reader("InterruptibleReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
try {
if (timeout < 0)
rl.lockInterruptibly();
else
rl.tryLock(timeout, unit);
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} catch (Throwable x) { thrown(x);
} finally { if (stamp() != 0L) rl.unlock(); } }};
}
static Reader interruptibleReaderView(final StampedLock sl,
final long timeout,
final TimeUnit unit,
final Phaser gate) {
return new Reader("InterruptibleReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
try {
if (timeout < 0)
rl.lockInterruptibly();
else
rl.tryLock(timeout, unit);
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} catch (Throwable x) { thrown(x);
} finally { if (stamp() != 0L) rl.unlock(); } }};
}
static Reader interruptibleReaderView(final StampedLock sl,
final long timeout,
final TimeUnit unit,
final Phaser gate) {
return new Reader("InterruptibleReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
try {
if (timeout < 0)
rl.lockInterruptibly();
else
rl.tryLock(timeout, unit);
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} catch (Throwable x) { thrown(x);
} finally { if (stamp() != 0L) rl.unlock(); } }};
}
static Reader interruptibleReaderView(final StampedLock sl,
final long timeout,
final TimeUnit unit,
final Phaser gate) {
return new Reader("InterruptibleReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
try {
if (timeout < 0)
rl.lockInterruptibly();
else
rl.tryLock(timeout, unit);
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} catch (Throwable x) { thrown(x);
} finally { if (stamp() != 0L) rl.unlock(); } }};
}
static Reader interruptibleReaderView(final StampedLock sl,
final long timeout,
final TimeUnit unit,
final Phaser gate) {
return new Reader("InterruptibleReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
try {
if (timeout < 0)
rl.lockInterruptibly();
else
rl.tryLock(timeout, unit);
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} catch (Throwable x) { thrown(x);
} finally { if (stamp() != 0L) rl.unlock(); } }};
}
static Reader interruptibleReaderView(final StampedLock sl,
final long timeout,
final TimeUnit unit,
final Phaser gate) {
return new Reader("InterruptibleReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
try {
if (timeout < 0)
rl.lockInterruptibly();
else
rl.tryLock(timeout, unit);
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} catch (Throwable x) { thrown(x);
} finally { if (stamp() != 0L) rl.unlock(); } }};
}
static Reader readerView(final StampedLock sl, final Phaser gate) {
return new Reader("ReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
rl.lock();
try {
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} finally { rl.unlock(); } }};
}
static Reader readerView(final StampedLock sl, final Phaser gate) {
return new Reader("ReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
rl.lock();
try {
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} finally { rl.unlock(); } }};
}
static Reader readerView(final StampedLock sl, final Phaser gate) {
return new Reader("ReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
rl.lock();
try {
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} finally { rl.unlock(); } }};
}
static Reader readerView(final StampedLock sl, final Phaser gate) {
return new Reader("ReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
rl.lock();
try {
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} finally { rl.unlock(); } }};
}
static Reader readerView(final StampedLock sl, final Phaser gate) {
return new Reader("ReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
rl.lock();
try {
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} finally { rl.unlock(); } }};
}
static Reader readerView(final StampedLock sl, final Phaser gate) {
return new Reader("ReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
rl.lock();
try {
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} finally { rl.unlock(); } }};
}
static Reader readerView(final StampedLock sl, final Phaser gate) {
return new Reader("ReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
rl.lock();
try {
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} finally { rl.unlock(); } }};
}
static Reader readerView(final StampedLock sl, final Phaser gate) {
return new Reader("ReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
rl.lock();
try {
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} finally { rl.unlock(); } }};
}
static Reader readerView(final StampedLock sl, final Phaser gate) {
return new Reader("ReaderView") { public void run() {
if (gate != null ) toTheStartingGate(gate);
final Lock rl = sl.asReadLock();
rl.lock();
try {
stamp(1L); // got the lock
check(sl.isReadLocked());
check(!sl.isWriteLocked());
} finally { rl.unlock(); } }};
}