public abstract static class Lock.With
extends java.lang.Object
Constructor and Description |
---|
With(Lock lock,
long lockWaitTimeout)
Constructs an executor that will grab the named lock.
|
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. |
public With(Lock lock, long lockWaitTimeout)
protected abstract java.lang.Object doBody() throws java.io.IOException
java.io.IOException
public java.lang.Object run() throws LockObtainFailedException, java.io.IOException
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.LockObtainFailedException
- if lock could not
be obtainedjava.io.IOException
- if Lock.obtain()
throws IOExceptionCopyright © 2000-2022 Apache Software Foundation. All Rights Reserved.