public class Promise<T>
extends java.lang.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.| 构造器和说明 |
|---|
Promise() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected T |
_getResultWithTimeout(long timeout)
Blocks until a result is available, or timeout milliseconds have elapsed.
|
java.util.concurrent.locks.Condition |
getCond() |
java.util.concurrent.locks.Lock |
getLock() |
T |
getResult() |
T |
getResult(long timeout)
Returns the result, but never throws a TimeoutException; returns null instead.
|
T |
getResult(long timeout,
boolean reset) |
T |
getResultWithTimeout(long timeout)
Blocks until a result is available, or timeout milliseconds have elapsed
|
T |
getResultWithTimeout(long timeout,
boolean reset) |
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
|
java.lang.String |
toString() |
public java.util.concurrent.locks.Lock getLock()
public java.util.concurrent.locks.Condition getCond()
public T getResultWithTimeout(long timeout) throws TimeoutException
timeout - in msTimeoutException - If a timeout occurred (implies that timeout > 0)public T getResultWithTimeout(long timeout, boolean reset) throws TimeoutException
TimeoutExceptionpublic T getResult()
public T getResult(long timeout)
timeout - in mspublic T getResult(long timeout, boolean reset)
public boolean hasResult()
public void setResult(T obj)
public void reset()
public java.lang.String toString()
toString 在类中 java.lang.Objectprotected T _getResultWithTimeout(long timeout) throws TimeoutException
timeout - in msTimeoutException - If a timeout occurred (implies that timeout > 0)