org.apache.lucene.store

Class Lock.With

public abstract static class Lock.With extends Object

Utility class for executing code with exclusive access.
Constructor Summary
With(Lock lock)
Constructs an executor that will grab the named lock.
With(Lock lock, long lockWaitTimeout)
Constructs an executor that will grab the named lock.
Method Summary
protected abstract ObjectdoBody()
Code to execute with exclusive access.
Objectrun()
Calls {@link #doBody} while lock is obtained.

Constructor Detail

With

public With(Lock lock)

Deprecated: Kept only to avoid breaking existing code.

Constructs an executor that will grab the named lock. Defaults lockWaitTimeout to Lock.COMMIT_LOCK_TIMEOUT.

With

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

Method Detail

doBody

protected abstract Object doBody()
Code to execute with exclusive access.

run

public Object run()
Calls {@link #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 {@link #doBody} exits.
Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.