Skip to content

Most visited

Recently visited

navigation

IdlingScheduledThreadPoolExecutor

public class IdlingScheduledThreadPoolExecutor
extends ScheduledThreadPoolExecutor implements IdlingResource

java.lang.Object
   ↳ java.util.concurrent.AbstractExecutorService
     ↳ java.util.concurrent.ThreadPoolExecutor
       ↳ java.util.concurrent.ScheduledThreadPoolExecutor
         ↳ android.support.test.espresso.idling.concurrent.IdlingScheduledThreadPoolExecutor


A ScheduledThreadPoolExecutor 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

IdlingScheduledThreadPoolExecutor(String resourceName, int corePoolSize, ThreadFactory threadFactory)

Creates a new IdlingScheduledThreadPoolExecutor with the given initial parameters.

Public methods

String getName()

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

boolean isIdleNow()

Returns true if resource is currently idle.

void registerIdleTransitionCallback(IdlingResource.ResourceCallback callback)

Registers the given IdlingResource.ResourceCallback with the resource.

<V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)

Protected methods

void afterExecute(Runnable r, Throwable t)
void beforeExecute(Thread t, Runnable r)
void terminated()

Inherited methods

From class java.util.concurrent.ScheduledThreadPoolExecutor
From class java.util.concurrent.ThreadPoolExecutor
From class java.util.concurrent.AbstractExecutorService
From class java.lang.Object
From interface java.util.concurrent.ScheduledExecutorService
From interface java.util.concurrent.ExecutorService
From interface android.support.test.espresso.IdlingResource
From interface java.util.concurrent.Executor

Public constructors

IdlingScheduledThreadPoolExecutor

IdlingScheduledThreadPoolExecutor (String resourceName, 
                int corePoolSize, 
                ThreadFactory threadFactory)

Creates a new IdlingScheduledThreadPoolExecutor with the given initial parameters.

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.

threadFactory ThreadFactory: the factory to use when the executor creates a new thread.

Public methods

getName

String getName ()

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

Returns
String

isIdleNow

boolean isIdleNow ()

Returns true if resource is currently idle. Espresso will always call this method from the main thread, therefore it should be non-blocking and return immediately.

Returns
boolean

registerIdleTransitionCallback

void registerIdleTransitionCallback (IdlingResource.ResourceCallback callback)

Registers the given IdlingResource.ResourceCallback with the resource. Espresso will call this method:

  • with its implementation of IdlingResource.ResourceCallback so it can be notified asynchronously that your resource is idle
  • from the main thread, but you are free to execute the callback's onTransitionToIdle from any thread
  • once (when it is initially given a reference to your IdlingResource)

You only need to call this upon transition from busy to idle - if the resource is already idle when the method is called invoking the call back is optional and has no significant impact.

Parameters
callback IdlingResource.ResourceCallback

schedule

ScheduledFuture<V> schedule (Callable<V> callable, 
                long delay, 
                TimeUnit unit)

Parameters
callable Callable

delay long

unit TimeUnit

Returns
ScheduledFuture<V>

schedule

ScheduledFuture<?> schedule (Runnable command, 
                long delay, 
                TimeUnit unit)

Parameters
command Runnable

delay long

unit TimeUnit

Returns
ScheduledFuture<?>

Protected methods

afterExecute

void afterExecute (Runnable r, 
                Throwable t)

Parameters
r Runnable

t Throwable

beforeExecute

void beforeExecute (Thread t, 
                Runnable r)

Parameters
t Thread

r Runnable

terminated

void terminated ()

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.