ScheduledFuture
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
|
A delayed result-bearing action that can be cancelled.
Usually a scheduled future is the result of scheduling
a task with a ScheduledExecutorService
.
Inherited Method Summary
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.
|
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\u003eScheduledFuture\u003c/code\u003e represents a delayed result-bearing action that can be cancelled, typically used for scheduling tasks.\u003c/p\u003e\n"],["\u003cp\u003eIt extends the \u003ccode\u003eDelayed\u003c/code\u003e and \u003ccode\u003eFuture\u003c/code\u003e interfaces, providing methods to manage delays, cancellation, and retrieval of results.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eScheduledExecutorService\u003c/code\u003e is commonly used to create and manage instances of \u003ccode\u003eScheduledFuture\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe interface includes methods inherited from \u003ccode\u003eDelayed\u003c/code\u003e, \u003ccode\u003eFuture\u003c/code\u003e, and \u003ccode\u003eComparable\u003c/code\u003e for comprehensive task management.\u003c/p\u003e\n"]]],["`ScheduledFuture` is a cancellable, delayed action that produces a result, often from `ScheduledExecutorService`. It inherits methods to manage its state and retrieve results: `cancel`, `get` (with/without timeout), `isCancelled`, and `isDone`. It also features `getDelay` to check remaining delay time and `compareTo` for ordering, and `RunnableScheduledFuture` as subclass, that is a `Runnable`.\n"],null,["# ScheduledFuture\n\npublic interface **ScheduledFuture** implements [Delayed](../../../../reference/java/util/concurrent/Delayed.html) [Future](../../../../reference/java/util/concurrent/Future.html)\\\u003cV\\\u003e \n\n|---|---|---|\n| Known Indirect Subclasses [RunnableScheduledFuture](../../../../reference/java/util/concurrent/RunnableScheduledFuture.html)\\\u003cV\\\u003e |---------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| | [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 delayed result-bearing action that can be cancelled.\nUsually a scheduled future is the result of scheduling\na task with a [ScheduledExecutorService](../../../../reference/java/util/concurrent/ScheduledExecutorService.html). \n\n### Inherited Method Summary\n\nFrom interface [java.util.concurrent.Delayed](../../../../reference/java/util/concurrent/Delayed.html) \n\n|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract long | [getDelay](../../../../reference/java/util/concurrent/Delayed.html#getDelay(java.util.concurrent.TimeUnit))([TimeUnit](../../../../reference/java/util/concurrent/TimeUnit.html) unit) Returns the remaining delay associated with this object, in the given time unit. |\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\nFrom interface [java.lang.Comparable](../../../../reference/java/lang/Comparable.html) \n\n|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract int | [compareTo](../../../../reference/java/lang/Comparable.html#compareTo(T))([Delayed](../../../../reference/java/util/concurrent/Delayed.html) o) Compares this object with the specified object for order. |"]]