Future

An object representing the result of a task that may not have finished yet; get waits for it.

In more detail

get blocks the calling thread until the result is ready, so in a service always use the version with a timeout or compose the work asynchronously instead. If the task failed, get throws an exception wrapping the cause.

Example

Future<Integer> result = pool.submit(() -> 6 * 7);  result.get();

Related terms

Taught in

References

Certification courses