Interface AwaitableRunnable
-
- All Superinterfaces:
Runnable
- All Known Implementing Classes:
AwaitableNoOpRunnable
,PausingAwaitableNoOpRunnable
public interface AwaitableRunnable extends Runnable
A Runnable that signals that it has finished running. Task completion can be awaited via theawaitTaskCompletion()
method. Task status (finished or not) can be observed via thehasTaskFinished()
method.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
awaitTaskCompletion()
Block until the task has finished running.boolean
awaitTaskCompletion(long amount, TimeUnit unit)
Block until the task has finished running, or until a timeout has expired.boolean
hasTaskFinished()
Has the task finished?
-
-
-
Method Detail
-
hasTaskFinished
boolean hasTaskFinished()
Has the task finished?- Returns:
- True if the task has finished.
-
awaitTaskCompletion
void awaitTaskCompletion() throws InterruptedException
Block until the task has finished running.- Throws:
InterruptedException
- If the thread was interrupted while waiting.
-
awaitTaskCompletion
boolean awaitTaskCompletion(long amount, TimeUnit unit) throws InterruptedException
Block until the task has finished running, or until a timeout has expired.- Parameters:
amount
- The duration of the timeout.unit
- The units of the amount parameter.- Returns:
- True if the task completed before the timeout expired; false if it did not.
- Throws:
InterruptedException
- If the thread was interrupted while waiting.
-
-