public class DeterministicExecutor
extends java.lang.Object
implements java.util.concurrent.Executor
Executor that executes commands on the thread that calls
runPendingCommands or runUntilIdle.
This is useful when using Mock Objects to test code that spawns background tasks.| Constructor and Description |
|---|
DeterministicExecutor() |
| Modifier and Type | Method and Description |
|---|---|
void |
execute(java.lang.Runnable command) |
boolean |
isIdle()
Returns whether this executor is idle -- has no pending background tasks waiting to be run.
|
void |
runPendingCommands()
Runs all commands that are currently pending.
|
void |
runUntilIdle()
Runs executed commands until there are no commands pending execution, but
does not tick time forward.
|
public boolean isIdle()
runPendingCommands(),
runUntilIdle()public void runPendingCommands()
runPendingCommands() or
runUntilIdle().public void runUntilIdle()
public void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executor