public class

IdlingThreadPoolExecutor

extends ThreadPoolExecutor
implements IdlingResource
java.lang.Object
   ↳ java.util.concurrent.AbstractExecutorService
     ↳ java.util.concurrent.ThreadPoolExecutor
       ↳ android.support.test.espresso.idling.concurrent.IdlingThreadPoolExecutor

Class Overview

A ThreadPoolExecutor that can be registered as an IdlingResource with Espresso.

Overrides parent methods to monitor threads starting, and finishing execution. Uses CountingIdlingResource to track number of active tasks.

This API is currently in beta.

Summary

Public Constructors
IdlingThreadPoolExecutor(String resourceName, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
Creates a new IdlingThreadPoolExecutor with the given initial parameters and default rejected execution handler.
Public Methods
void execute(Runnable command)
String getName()
boolean isIdleNow()
void registerIdleTransitionCallback(IdlingResource.ResourceCallback callback)
Protected Methods
void afterExecute(Runnable r, Throwable t)
void terminated()
[Expand]
Inherited Methods
From class java.util.concurrent.ThreadPoolExecutor
From class java.util.concurrent.AbstractExecutorService
From class java.lang.Object
From interface java.util.concurrent.ExecutorService
From interface android.support.test.espresso.IdlingResource
From interface java.util.concurrent.Executor

Public Constructors

public IdlingThreadPoolExecutor (String resourceName, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)

Creates a new IdlingThreadPoolExecutor with the given initial parameters and default rejected execution handler.

Parameters
resourceName String: the name of the executor (used for logging and idempotency of registration).
corePoolSize int: the number of threads to keep in the pool, even if they are idle, unless allowCoreThreadTimeOut is set.
maximumPoolSize int: the maximum number of threads to allow in the pool.
keepAliveTime long: when the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.
unit TimeUnit: the time unit for the keepAliveTime argument.
workQueue BlockingQueue: the queue to use for holding tasks before they are executed. This queue will hold only the Runnable tasks submitted by the execute method.
threadFactory ThreadFactory: the factory to use when the executor creates a new thread.

Public Methods

public void execute (Runnable command)

Parameters
command Runnable

public String getName ()

Returns
String

public boolean isIdleNow ()

Returns
boolean

public void registerIdleTransitionCallback (IdlingResource.ResourceCallback callback)

Parameters
callback IdlingResource.ResourceCallback

Protected Methods

protected void afterExecute (Runnable r, Throwable t)

Parameters
r Runnable
t Throwable

protected void terminated ()