Package io.keikai.model.util
Class ReadWriteTask<T>
java.lang.Object
io.keikai.model.util.ReadWriteTask<T>
Use this class to help you concurrently access book model safely.
Usage: implement your model-accessing logic in invoke() method.
- Since:
- 3.5.0
- Author:
- dennis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoInReadLock(ReadWriteLock lock) Call invoke() after acquiring a read lock, and then release it.doInWriteLock(ReadWriteLock lock) Call invoke() after acquiring a write lock, and then release it.abstract Tinvoke()The method will be invoked after acquiring a read-write lock and release the lock after invocation.
-
Constructor Details
-
ReadWriteTask
public ReadWriteTask()
-
-
Method Details
-
invoke
The method will be invoked after acquiring a read-write lock and release the lock after invocation. So implement your model-accessing logic in this method.- Returns:
- depends on your logic
-
doInWriteLock
Call invoke() after acquiring a write lock, and then release it. -
doInReadLock
Call invoke() after acquiring a read lock, and then release it.
-