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 |
handle(ReadLockHandler<T> readLockHandler)
操作obj时,带上读锁
|
void |
handle(WriteLockHandler<T> writeLockHandler)
操作obj时,带上写锁
|
ReentrantReadWriteLock.ReadLock |
readLock()
获取读锁
|
void |
setObj(T obj) |
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 handle(ReadLockHandler<T> readLockHandler)
readLockHandler
- public void handle(WriteLockHandler<T> writeLockHandler)
writeLockHandler
- Copyright © 2021. All rights reserved.