Interface MonitorableTaskExecutor

All Superinterfaces:
ContextAwareTaskExecutor, Executor, TaskExecutor
All Known Subinterfaces:
MonitorableTaskExecutorService
All Known Implementing Classes:
SingleThreadedExecutor, SyncTaskExecutor, ThreadPoolTaskExecutor

public interface MonitorableTaskExecutor extends ContextAwareTaskExecutor
Defines a TaskExecutor which is able to provide a few statistical information about the currently queued tasks. This information cannot be used for synchronization purposes and should be considered unreliable. However, you can base some decision on these methods: For example, if the number of queued tasks exceed a predefined constant, you may decide to schedule tasks slower to the executor.

Thread safety

Implementations of this interface are required to be safely accessible from multiple threads concurrently.

Synchronization transparency

The methods of this interface are not required to be synchronization transparent because they may execute tasks, completion handlers tasks, etc.
  • Method Details

    • getNumberOfQueuedTasks

      long getNumberOfQueuedTasks()
      Returns the approximate number of tasks currently queued to this executor. The queued tasks are not currently executing but are scheduled to be executed in the future.

      Note that the value returned by this method should be considered unreliable and cannot be used for synchronization purposes.

      Returns:
      the approximate number of tasks currently queued to this executor. This method always returns a value greater than or equal to zero.
    • getNumberOfExecutingTasks

      long getNumberOfExecutingTasks()
      Returns the approximate number of tasks currently being executed.

      Note that the value returned by this method should be considered unreliable and cannot be used for synchronization purposes.

      Returns:
      the approximate number of tasks currently being executed. This method always returns a value greater than or equal to zero.