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