Stay organized with collections Save and categorize content based on your preferences.

IdlingThreadPoolExecutor

public class IdlingThreadPoolExecutor extends ThreadPoolExecutor


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

synchronized void
execute(Runnable command)
String
boolean
void
registerIdleTransitionCallback(ResourceCallback callback)

Public constructors

IdlingThreadPoolExecutor

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
String resourceName

the name of the executor (used for logging and idempotency of registration).

int corePoolSize

the number of threads to keep in the pool, even if they are idle, unless allowCoreThreadTimeOut is set.

int maximumPoolSize

the maximum number of threads to allow in the pool.

long keepAliveTime

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.

TimeUnit unit

the time unit for the keepAliveTime argument.

BlockingQueue<Runnable> workQueue

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

execute

synchronized public void execute(Runnable command)

getName

public String getName()

isIdleNow

public boolean isIdleNow()

registerIdleTransitionCallback

public void registerIdleTransitionCallback(ResourceCallback callback)