|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
public interface ReadWriteLock
ReadWriteLocks maintain a pair of associated locks. The readLock may be held simultanously by multiple reader threads, so long as there are no writers. The writeLock is exclusive. ReadWrite locks are generally preferable to plain Sync locks or synchronized methods in cases where:
Standard usage:
class X {
ReadWriteLock rw;
// ...
public void read() throws InterruptedException {
rw.readLock().acquire();
try {
// ... do the read
}
finally {
rw.readlock().release()
}
}
public void write() throws InterruptedException {
rw.writeLock().acquire();
try {
// ... do the write
}
finally {
rw.writelock().release()
}
}
}
| 方法摘要 | |
|---|---|
Sync |
readLock()
get the readLock |
Sync |
writeLock()
get the writeLock |
| 方法详细信息 |
|---|
Sync readLock()
Sync writeLock()
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||