Interface PausingRunnable
-
- All Superinterfaces:
Runnable
- All Known Implementing Classes:
PausingAwaitableNoOpRunnable
,PausingNoOpRunnable
public interface PausingRunnable extends Runnable
A Runnable that pauses (waiting for a call tounpause()
) at the start of itsRunnable.run()
method.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
hasPaused()
Has the PausingRunnable paused yet? If it has been unpaused this will also return true.boolean
hasUnpaused()
Has the PausingRunnable been paused and then unpaused?void
unpause()
Release a paused PausingRunnable so that it can continue running.void
waitUntilPaused()
Block the current thread indefinitely, until the PausingRunnable is paused.boolean
waitUntilPaused(long amount, TimeUnit unit)
Block the current thread until the PausingRunnable is paused, unless a timeout has expired while waiting.
-
-
-
Method Detail
-
hasPaused
boolean hasPaused()
Has the PausingRunnable paused yet? If it has been unpaused this will also return true.- Returns:
- true if it is paused, or was previously paused and has been unpaused.
-
waitUntilPaused
void waitUntilPaused() throws InterruptedException
Block the current thread indefinitely, until the PausingRunnable is paused.- Throws:
InterruptedException
- if the thread that is waiting is interrupted.
-
waitUntilPaused
boolean waitUntilPaused(long amount, TimeUnit unit) throws InterruptedException
Block the current thread until the PausingRunnable is paused, unless a timeout has expired while waiting. If the timeout expires, this method will return false.- Parameters:
amount
- The magnitude of the timeout value.unit
- The units of the timeout value.- Returns:
- true if the PausingRunnable paused before the timeout expired, or false if the timeout expired before the PausingRunnable paused.
- Throws:
InterruptedException
- if the thread that is waiting is interrupted.
-
unpause
void unpause()
Release a paused PausingRunnable so that it can continue running.
-
hasUnpaused
boolean hasUnpaused()
Has the PausingRunnable been paused and then unpaused?- Returns:
- true if it has been unpaused.
-
-