public class Promise<T> extends Object
hasResult()
will always return true and getResult()
will return the
same result. In order to block for a different result, reset()
has to be called first.Constructor and Description |
---|
Promise() |
Modifier and Type | Method and Description |
---|---|
protected T |
_getResultWithTimeout(long timeout)
Blocks until a result is available, or timeout milliseconds have elapsed.
|
Condition |
getCond() |
Lock |
getLock() |
T |
getResult() |
T |
getResult(long timeout)
Returns the result, but never throws a TimeoutException; returns null instead.
|
T |
getResultWithTimeout(long timeout)
Blocks until a result is available, or timeout milliseconds have elapsed
|
boolean |
hasResult()
Checks whether result is available.
|
void |
reset()
Causes all waiting threads to return
|
void |
setResult(T obj)
Sets the result and notifies any threads waiting for it
|
String |
toString() |
public Lock getLock()
public Condition getCond()
public T getResultWithTimeout(long timeout) throws TimeoutException
timeout
- in msTimeoutException
- If a timeout occurred (implies that timeout > 0)public T getResult()
public T getResult(long timeout)
timeout
- in mspublic boolean hasResult()
public void setResult(T obj)
public void reset()
protected T _getResultWithTimeout(long timeout) throws TimeoutException
timeout
- in msTimeoutException
- If a timeout occurred (implies that timeout > 0)Copyright © 2014 JBoss, a division of Red Hat. All rights reserved.