public class Future<T>
extends java.lang.Object
implements java.util.concurrent.Future<T>
Future
Modifier and Type | Field and Description |
---|---|
protected boolean |
cancelled |
protected java.lang.Throwable |
exception |
protected boolean |
hasResult |
protected T |
result |
Constructor and Description |
---|
Future() |
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterrupt)
This method makes the waiting thread return with a
CancellationException but does not cancel the actual
operation the thread was waiting for.
|
void |
complete(T val) |
void |
error(java.lang.Throwable exception) |
T |
get()
Convenience method for get(0, TimeUnit.MILLISECONDS).
|
T |
get(long timeout)
Convenience method for get(timeout, TimeUnit.MILLISECONDS).
|
T |
get(long timeout,
java.util.concurrent.TimeUnit unit)
Gets the results passed to this callback object.
|
boolean |
isCancelled() |
boolean |
isDone()
Checks whether results are already available.
|
protected java.lang.Throwable exception
protected T result
protected boolean hasResult
protected boolean cancelled
public void complete(T val)
public void error(java.lang.Throwable exception)
public boolean cancel(boolean mayInterrupt)
cancel
in interface java.util.concurrent.Future<T>
mayInterrupt
- public T get() throws java.util.concurrent.ExecutionException
get
in interface java.util.concurrent.Future<T>
java.util.concurrent.ExecutionException
get(long, TimeUnit)
public T get(long timeout) throws java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
get(long, TimeUnit)
public T get(long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get
in interface java.util.concurrent.Future<T>
timeout
- number of TimeUnits to wait for results to become
availableunit
- TimeUnit to usejava.util.concurrent.ExecutionException
- if the operation resulted in an Exceptionjava.util.concurrent.TimeoutException
- if the timeout was reached before results were
availableget(long, TimeUnit)
public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<T>
public boolean isDone()
isDone
in interface java.util.concurrent.Future<T>