RunnableFuture
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
|
A Future
that is Runnable
. Successful execution of
the run
method causes completion of the Future
and allows access to its results.
Public Method Summary
abstract
void
|
run()
Sets this Future to the result of its computation
unless it has been cancelled.
|
Inherited Method Summary
From interface
java.lang.Runnable
abstract
void
|
run()
When an object implementing interface Runnable is used
to create a thread, starting the thread causes the object's
run method to be called in that separately executing
thread.
|
From interface
java.util.concurrent.Future
abstract
boolean
|
cancel(boolean mayInterruptIfRunning)
Attempts to cancel execution of this task.
|
abstract
V
|
get(long timeout, TimeUnit unit)
Waits if necessary for at most the given time for the computation
to complete, and then retrieves its result, if available.
|
abstract
V
|
get()
Waits if necessary for the computation to complete, and then
retrieves its result.
|
abstract
boolean
|
isCancelled()
Returns true if this task was cancelled before it completed
normally.
|
abstract
boolean
|
isDone()
Returns true if this task completed.
|
Public Methods
public
abstract
void
run
()
Sets this Future to the result of its computation
unless it has been cancelled.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eRunnableFuture\u003c/code\u003e combines the capabilities of \u003ccode\u003eRunnable\u003c/code\u003e and \u003ccode\u003eFuture\u003c/code\u003e, allowing an asynchronous computation to be executed and its result retrieved.\u003c/p\u003e\n"],["\u003cp\u003eRunning the \u003ccode\u003erun()\u003c/code\u003e method marks the \u003ccode\u003eFuture\u003c/code\u003e as complete and makes its result accessible.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eRunnableFuture\u003c/code\u003e supports cancellation and provides methods to check completion status and retrieve results.\u003c/p\u003e\n"],["\u003cp\u003eKey implementations include \u003ccode\u003eFutureTask\u003c/code\u003e and \u003ccode\u003eRunnableScheduledFuture\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# RunnableFuture\n\npublic interface **RunnableFuture** implements [Runnable](../../../../reference/java/lang/Runnable.html) [Future](../../../../reference/java/util/concurrent/Future.html)\\\u003cV\\\u003e \n\n|---|---|---|\n| Known Indirect Subclasses [FutureTask](../../../../reference/java/util/concurrent/FutureTask.html)\\\u003cV\\\u003e, [RunnableScheduledFuture](../../../../reference/java/util/concurrent/RunnableScheduledFuture.html)\\\u003cV\\\u003e |---------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| | [FutureTask](../../../../reference/java/util/concurrent/FutureTask.html)\\\u003cV\\\u003e | A cancellable asynchronous computation. | | [RunnableScheduledFuture](../../../../reference/java/util/concurrent/RunnableScheduledFuture.html)\\\u003cV\\\u003e | A [ScheduledFuture](../../../../reference/java/util/concurrent/ScheduledFuture.html) that is [Runnable](../../../../reference/java/lang/Runnable.html). | |||\n\nA [Future](../../../../reference/java/util/concurrent/Future.html) that is [Runnable](../../../../reference/java/lang/Runnable.html). Successful execution of\nthe `run` method causes completion of the `Future`\nand allows access to its results. \n\n##### See Also\n\n- [FutureTask](../../../../reference/java/util/concurrent/FutureTask.html)\n- [Executor](../../../../reference/java/util/concurrent/Executor.html) \n\n### Public Method Summary\n\n|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [run](../../../../reference/java/util/concurrent/RunnableFuture.html#run())() Sets this Future to the result of its computation unless it has been cancelled. |\n\n### Inherited Method Summary\n\nFrom interface [java.lang.Runnable](../../../../reference/java/lang/Runnable.html) \n\n|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [run](../../../../reference/java/lang/Runnable.html#run())() When an object implementing interface `Runnable` is used to create a thread, starting the thread causes the object's `run` method to be called in that separately executing thread. |\n\nFrom interface [java.util.concurrent.Future](../../../../reference/java/util/concurrent/Future.html) \n\n|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract boolean | [cancel](../../../../reference/java/util/concurrent/Future.html#cancel(boolean))(boolean mayInterruptIfRunning) Attempts to cancel execution of this task. |\n| abstract V | [get](../../../../reference/java/util/concurrent/Future.html#get(long,%20java.util.concurrent.TimeUnit))(long timeout, [TimeUnit](../../../../reference/java/util/concurrent/TimeUnit.html) unit) Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available. |\n| abstract V | [get](../../../../reference/java/util/concurrent/Future.html#get())() Waits if necessary for the computation to complete, and then retrieves its result. |\n| abstract boolean | [isCancelled](../../../../reference/java/util/concurrent/Future.html#isCancelled())() Returns `true` if this task was cancelled before it completed normally. |\n| abstract boolean | [isDone](../../../../reference/java/util/concurrent/Future.html#isDone())() Returns `true` if this task completed. |\n\nPublic Methods\n--------------\n\n#### public abstract void\n**run**\n()\n\nSets this Future to the result of its computation\nunless it has been cancelled."]]