org.jgroups.util
Class Promise
public class Promise
extends java.lang.Object
Allows a thread to submit an asynchronous request and to wait for the result. The caller may choose to check
for the result at a later time, or immediately and it may block or not. Both the caller and responder have to
know the promise.
Object | getResult(long timeout) - Gets result.
|
boolean | hasResult() - Checks whether result is available.
|
void | reset() - Causes all waiting threads to return
|
void | setResult(Object obj) - Sets the result and notifies any threads
waiting for it
|
String | toString()
|
getResult
public Object getResult(long timeout)
Gets result. If result was already submitted,
returns it immediately (resetting it), else blocks
until
results get available.
timeout
- Max time to wait for result. If it
is 0, we wait indefinitely
hasResult
public boolean hasResult()
Checks whether result is available. Does not block.
reset
public void reset()
Causes all waiting threads to return
setResult
public void setResult(Object obj)
Sets the result and notifies any threads
waiting for it
toString
public String toString()
Copyright B) 2001,2002 www.jgroups.com . All Rights Reserved.