Class PausingNoOpRunnable
- java.lang.Object
-
- com.pervasivecode.utils.concurrent.testing.PausingNoOpRunnable
-
- All Implemented Interfaces:
PausingRunnable
,Runnable
public final class PausingNoOpRunnable extends Object implements PausingRunnable
A simple Runnable that will pause until released. When released, it finishes running immediately.
-
-
Constructor Summary
Constructors Constructor Description PausingNoOpRunnable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
int
hashCode()
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
onPause(Runnable onPauseHandler)
void
run()
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
public boolean hasPaused()
Description copied from interface:PausingRunnable
Has the PausingRunnable paused yet? If it has been unpaused this will also return true.- Specified by:
hasPaused
in interfacePausingRunnable
- Returns:
- true if it is paused, or was previously paused and has been unpaused.
-
waitUntilPaused
public void waitUntilPaused() throws InterruptedException
Description copied from interface:PausingRunnable
Block the current thread indefinitely, until the PausingRunnable is paused.- Specified by:
waitUntilPaused
in interfacePausingRunnable
- Throws:
InterruptedException
- if the thread that is waiting is interrupted.
-
waitUntilPaused
public boolean waitUntilPaused(long amount, TimeUnit unit) throws InterruptedException
Description copied from interface:PausingRunnable
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.- Specified by:
waitUntilPaused
in interfacePausingRunnable
- 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
public void unpause()
Description copied from interface:PausingRunnable
Release a paused PausingRunnable so that it can continue running.- Specified by:
unpause
in interfacePausingRunnable
-
hasUnpaused
public boolean hasUnpaused()
Description copied from interface:PausingRunnable
Has the PausingRunnable been paused and then unpaused?- Specified by:
hasUnpaused
in interfacePausingRunnable
- Returns:
- true if it has been unpaused.
-
onPause
public void onPause(Runnable onPauseHandler)
-
-