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
- ExecutorService — The standard-library service that owns a pool of worker threads and runs tasks you submit to it, returning a Future for each.
- Callable — The functional interface for a task that returns a result and may throw an exception, submitted to an executor.
- CompletableFuture — A Future that can be completed later and chained, letting you describe asynchronous steps such as transform, combine and recover without nesting callbacks.
- blocking call — A call that makes the current thread wait, doing nothing else, until some result or event arrives.
- timeout — A limit on how long a caller waits for an answer before giving up.
Taught in
- The ExecutorService — Modern Java: Virtual Threads & High-Throughput Services
- Platform And Virtual Threads, Runnable And Callable — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Modules And Concurrency — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Mock Exam: Sit It, Score It — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Final Review And Exam Day — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep