org.apache.lucene.store

## Class Lock.With

- java.lang.Object
- - org.apache.lucene.store.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 and Description
    `With(Lock lock, long lockWaitTimeout)` Constructs an executor that will grab the named lock.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract java.lang.Object` | `doBody()` Code to execute with exclusive access.
    `java.lang.Object` | `run()` Calls `doBody()` while lock is obtained.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, 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

    - #### doBody

          protected abstract java.lang.Object doBody()
                                              throws java.io.IOException

      Code to execute with exclusive access.
      Throws:
        `java.io.IOException`

    - #### run

          public java.lang.Object run()
                               throws LockObtainFailedException,
                                      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

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.