Executor, ExecutorService@Beta public class InlineExecutorService extends Object implements ExecutorService
RoboExecutorService when using
LooperMode.Mode.PAUSED.
Unlike RoboExecutorService, will execute tasks on a background thread. This is useful
to test Android code that enforces it runs off the main thread.
Also consider using MoreExecutors.directExecutor(), if your code under test can handle
being called from main thread.
Also see PausedExecutorService if you need control over when posted tasks are executed.
NOTE: Beta API, subject to change.| Constructor | Description |
|---|---|
InlineExecutorService() |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
awaitTermination(long l,
TimeUnit timeUnit) |
|
void |
execute(Runnable command) |
|
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks) |
|
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
|
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks) |
|
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
|
boolean |
isShutdown() |
|
boolean |
isTerminated() |
|
void |
shutdown() |
|
List<Runnable> |
shutdownNow() |
|
Future<?> |
submit(Runnable task) |
|
<T> Future<T> |
submit(Runnable task,
T result) |
|
<T> Future<T> |
submit(Callable<T> task) |
public void shutdown()
shutdown in interface ExecutorServicepublic List<Runnable> shutdownNow()
shutdownNow in interface ExecutorServicepublic boolean isShutdown()
isShutdown in interface ExecutorServicepublic boolean isTerminated()
isTerminated in interface ExecutorServicepublic boolean awaitTermination(long l,
TimeUnit timeUnit)
throws InterruptedException
awaitTermination in interface ExecutorServiceInterruptedException@NonNull public <T> Future<T> submit(@NonNull Callable<T> task)
submit in interface ExecutorService@NonNull public <T> Future<T> submit(@NonNull Runnable task, T result)
submit in interface ExecutorService@NonNull public Future<?> submit(@NonNull Runnable task)
submit in interface ExecutorService@NonNull public <T> List<Future<T>> invokeAll(@NonNull Collection<? extends Callable<T>> tasks) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedException@NonNull public <T> List<Future<T>> invokeAll(@NonNull Collection<? extends Callable<T>> tasks, long timeout, @NonNull TimeUnit unit) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedException@NonNull
public <T> T invokeAny(@NonNull
Collection<? extends Callable<T>> tasks)
throws ExecutionException,
InterruptedException
invokeAny in interface ExecutorServiceExecutionExceptionInterruptedExceptionpublic <T> T invokeAny(@NonNull
Collection<? extends Callable<T>> tasks,
long timeout,
@NonNull
TimeUnit unit)
throws ExecutionException,
InterruptedException,
TimeoutException
invokeAny in interface ExecutorServiceExecutionExceptionInterruptedExceptionTimeoutException