Class Lock.With

  • Enclosing class:
    Lock

    public abstract static class Lock.With
    extends java.lang.Object
    Utility class for executing code with exclusive access.
    • Constructor Summary

      Constructors 
      Constructor Description
      With​(Lock lock, long lockWaitTimeout)
      Constructs an executor that will grab the named lock.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object run()
      Calls doBody() while lock is obtained.
      • Methods inherited from class java.lang.Object

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

      • With

        public With​(Lock lock,
                    long lockWaitTimeout)
        Constructs an executor that will grab the named lock.
    • Method Detail

      • run

        public java.lang.Object run()
                             throws java.io.IOException
        Calls doBody() while lock is obtained. Blocks if lock cannot be obtained immediately. Retries to obtain lock once per second until it is obtained, or until it has tried ten times. Lock is released when doBody() exits.
        Throws:
        LockObtainFailedException - if lock could not be obtained
        java.io.IOException - if Lock.obtain() throws IOException