T - 所涉及对象的类型public class ObjWithLock<T> extends Object implements Serializable
| Constructor and Description |
|---|
ObjWithLock(T obj)
构造对象
|
ObjWithLock(T obj,
ReentrantReadWriteLock lock)
构造对象
|
| Modifier and Type | Method and Description |
|---|---|
ReentrantReadWriteLock |
getLock()
获取读写锁
|
T |
getObj()
获取对象
|
void |
read(LockHandler<T> readLockHandler)
操作对象,带上读锁
|
ReentrantReadWriteLock.ReadLock |
readLock()
获取读锁
|
void |
setObj(T obj)
设置对象
|
void |
write(LockHandler<T> writeLockHandler)
操作对象,带上写锁
|
ReentrantReadWriteLock.WriteLock |
writeLock()
获取写锁
|
public ObjWithLock(T obj)
obj - 对象信息public ObjWithLock(T obj, ReentrantReadWriteLock lock)
obj - 对象信息lock - 读写锁public ReentrantReadWriteLock getLock()
public ReentrantReadWriteLock.WriteLock writeLock()
public ReentrantReadWriteLock.ReadLock readLock()
public T getObj()
public void setObj(T obj)
obj - 对象信息public void read(LockHandler<T> readLockHandler)
readLockHandler - 拦截锁public void write(LockHandler<T> writeLockHandler)
writeLockHandler - 拦截锁Copyright © 2022. All rights reserved.