Stay organized with collections
Save and categorize content based on your preferences.
RunnableScheduledFuture
interface RunnableScheduledFuture<V : Any!> : RunnableFuture<V>, ScheduledFuture<V>
A ScheduledFuture
that is Runnable
. Successful execution of the run
method causes completion of the Future
and allows access to its results.
Summary
Public methods |
abstract Boolean |
Returns true if this task is periodic.
|
Inherited functions |
From class Future
Boolean |
cancel(mayInterruptIfRunning: Boolean)
Attempts to cancel execution of this task. This method has no effect if the task is already completed or cancelled, or could not be cancelled for some other reason. Otherwise, if this task has not started when cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task (when known by the implementation) is interrupted in an attempt to stop the task.
The return value from this method does not necessarily indicate whether the task is now cancelled; use isCancelled .
|
Throwable! |
exceptionNow()
Returns the exception thrown by the task, without waiting.
This method is for cases where the caller knows that the task has already completed with an exception.
|
V |
get()
Waits if necessary for the computation to complete, and then retrieves its result.
|
V |
get(timeout: Long, unit: TimeUnit!)
Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
|
Boolean |
isCancelled()
Returns true if this task was cancelled before it completed normally.
|
Boolean |
isDone()
Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true .
|
V |
resultNow()
Returns the computed result, without waiting.
This method is for cases where the caller knows that the task has already completed successfully, for example when filtering a stream of Future objects for the successful tasks and using a mapping operation to obtain a stream of results. {@snippet lang=java : * results = futures.stream() * .filter(f -> f.state() == Future.State.SUCCESS) * .map(Future::resultNow) * .toList(); * }
|
Future.State! |
state()
{@return the computation state}
|
|
From class RunnableFuture
Unit |
run()
Sets this Future to the result of its computation unless it has been cancelled.
|
|
Public methods
isPeriodic
abstract fun isPeriodic(): Boolean
Returns true
if this task is periodic. A periodic task may re-run according to some schedule. A non-periodic task can be run only once.
Return |
Boolean |
true if this task is periodic |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-12-18 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-12-18 UTC."],[],[]]