public abstract class Future<T> extends Object
A future has the method get() which waits for the calculation to complete, and returns the result.
The client must create a subclass and implement the method populate() which will be run in the thread.
The reason for the creation of this class is the JVM-supplied Future object seemed too complex.
| Modifier and Type | Class and Description |
|---|---|
static class |
Future.FutureComputationTimedOutException |
static class |
Future.FuturePopulationException
An exception occurred during the population of this future
|
static class |
Future.IterableFuture<I>
An iterable whose values are computed in the background.
|
| Constructor and Description |
|---|
Future() |
| Modifier and Type | Method and Description |
|---|---|
T |
get()
Returns the object, waiting for its computation to be completed if necessary.
|
T |
getOrTimeoutAfterSeconds(float seconds)
Same as
get() but times out after 'seconds' seconds. |
protected String |
getThreadName() |
protected abstract T |
populate()
Calculate the result and return it.
|
protected abstract T populate()
protected String getThreadName()
public T getOrTimeoutAfterSeconds(float seconds) throws Future.FutureComputationTimedOutException, Future.FuturePopulationException
get() but times out after 'seconds' seconds.public T get()
Copyright © 2003–2018. All rights reserved.