Interface DwAsyncPool

All Known Implementing Classes:
DwAsyncPoolImpl

public interface DwAsyncPool
A thread pool allowing to run asynchronous tasks.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    awaitTermination(long timeout, TimeUnit unit)
    Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
    int
    Returns the approximate number of threads that are actively executing tasks.
    long
    Returns the approximate total number of tasks that have completed execution.
    int
    Returns the core number of threads.
    int
    Returns the current number of threads in the pool.
    long
    Returns the approximate total number of tasks that have ever been scheduled for execution.
    boolean
    Returns true if the pool has been shut down (orderly).
    boolean
    Returns true if the pool has been terminated
    void
    Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
    Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.
    <T> Future<T>
    Submits a Runnable task for execution and returns a Future representing that task.
    <T> Future<T>
    submit(Runnable task, T result)
    Submits a Runnable task for execution and returns a Future representing that task.
    <T> Future<T>
    submit(Callable<T> task)
    Submits a value-returning task for execution and returns a Future representing the pending results of the task.
  • Method Details

    • submit

      <T> Future<T> submit(Callable<T> task)
      Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future's get method will return the task's result upon successful completion.
      Parameters:
      task -
      See Also:
    • submit

      <T> Future<T> submit(Runnable task)
      Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return null upon successful completion.
      Parameters:
      task -
      See Also:
    • submit

      <T> Future<T> submit(Runnable task, T result)
      Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return the given result upon successful completion.
      Parameters:
      task -
      See Also:
    • getActiveCount

      int getActiveCount()
      Returns the approximate number of threads that are actively executing tasks.
      Returns:
      the number of threads
      See Also:
    • getTaskCount

      long getTaskCount()
      Returns the approximate total number of tasks that have ever been scheduled for execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation.
      Returns:
      the number of threads
      See Also:
    • getCompletedTaskCount

      long getCompletedTaskCount()
      Returns the approximate total number of tasks that have completed execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.
      Returns:
      the number of threads
      See Also:
    • getPoolSize

      int getPoolSize()
      Returns the current number of threads in the pool.
      Returns:
      the number of threads
      See Also:
    • getCorePoolSize

      int getCorePoolSize()
      Returns the core number of threads.
      Returns:
      the core number of threads
      See Also:
    • isShutdown

      boolean isShutdown()
      Returns true if the pool has been shut down (orderly).
    • isTerminated

      boolean isTerminated()
      Returns true if the pool has been terminated
    • awaitTermination

      boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
      Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
      Parameters:
      timeout -
      unit -
      Throws:
      InterruptedException
      See Also:
    • shutdown

      void shutdown()
      Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.

      This method does not wait for previously submitted tasks to complete execution. Use awaitTermination to do that.

      See Also:
    • shutdownNow

      List<Runnable> shutdownNow()
      Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.

      This method does not wait for actively executing tasks to terminate. Use awaitTermination to do that.

      There are no guarantees beyond best-effort attempts to stop processing actively executing tasks. For example, typical implementations will cancel via Thread.interrupt(), so any task that fails to respond to interrupts may never terminate.

      Returns:
      list of tasks that never commenced execution
      See Also: