Class ReadWriteTask<T>


  • public abstract class ReadWriteTask<T>
    extends java.lang.Object
    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 
      Constructor Description
      ReadWriteTask()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      T doInReadLock​(java.util.concurrent.locks.ReadWriteLock lock)
      Call invoke() after acquiring a read lock, and then release it.
      T doInWriteLock​(java.util.concurrent.locks.ReadWriteLock lock)
      Call invoke() after acquiring a write lock, and then release it.
      abstract T invoke()
      The method will be invoked after acquiring a read-write lock and release the lock after invocation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ReadWriteTask

        public ReadWriteTask()
    • Method Detail

      • invoke

        public abstract T 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

        public T doInWriteLock​(java.util.concurrent.locks.ReadWriteLock lock)
        Call invoke() after acquiring a write lock, and then release it.
      • doInReadLock

        public T doInReadLock​(java.util.concurrent.locks.ReadWriteLock lock)
        Call invoke() after acquiring a read lock, and then release it.