## org.apache.cassandra.concurrent
Class AIOExecutorService

    java.lang.Object
      org.apache.cassandra.concurrent.AIOExecutorService

All Implemented Interfaces:
  java.util.concurrent.Executor, java.util.concurrent.ExecutorService

    public class AIOExecutorService

extends java.lang.Object
implements java.util.concurrent.ExecutorService

Constructor Summary
`AIOExecutorService(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue, java.util.concurrent.ThreadFactory threadFactory)`

Method Summary
`boolean` `awaitTermination(long timeout, java.util.concurrent.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.
`void` `execute(java.lang.Runnable command)` Executes the given command at some time in the future.

`

`<T> java.util.List<java.util.concurrent.Future<T>>`

`

`invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)`
Executes the given tasks, returning a list of Futures holding their status and results when all complete.

`

`<T> java.util.List<java.util.concurrent.Future<T>>`

`

`invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)`
Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first.

`

`<T> T`

`

`invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)`
Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do.

`

`<T> T`

`

`invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)`
Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do before the given timeout elapses.

`boolean` `isShutdown()` Returns `true` if this executor has been shut down.
`boolean` `isTerminated()` Returns `true` if all tasks have completed following shut down.
`void` `shutdown()` Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
`java.util.List<java.lang.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.

`

`<T> java.util.concurrent.Future<T>`

`

`submit(java.util.concurrent.Callable<T> task)`
Submits a value-returning task for execution and returns a Future representing the pending results of the task.

`java.util.concurrent.Future<?>` `submit(java.lang.Runnable task)` Submits a Runnable task for execution and returns a Future representing that task.

`

`<T> java.util.concurrent.Future<T>`

`

`submit(java.lang.Runnable task, T result)`
Submits a Runnable task for execution and returns a Future representing that task.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AIOExecutorService

    public AIOExecutorService(int corePoolSize,
                              int maximumPoolSize,
                              long keepAliveTime,
                              java.util.concurrent.TimeUnit unit,
                              java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
                              java.util.concurrent.ThreadFactory threadFactory)

Method Detail

### execute

    public void execute(java.lang.Runnable command)

  Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the `Executor` implementation.

  Specified by:
    `execute` in interface `java.util.concurrent.Executor`
  Parameters:
    `command` - the runnable task
  Throws:
    `java.util.concurrent.RejectedExecutionException` - if this task cannot be accepted for execution.
    `java.lang.NullPointerException` - if command is null

### shutdown

    public 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.

  Specified by:
    `shutdown` in interface `java.util.concurrent.ExecutorService`
  Throws:
    `java.lang.SecurityException` - if a security manager exists and shutting down this ExecutorService may manipulate threads that the caller is not permitted to modify because it does not hold `RuntimePermission``("modifyThread")`, or the security manager's `checkAccess` method denies access.

### shutdownNow

    public java.util.List<java.lang.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.

  Specified by:
    `shutdownNow` in interface `java.util.concurrent.ExecutorService`
  Returns:
    list of tasks that never commenced execution
  Throws:
    `java.lang.SecurityException` - if a security manager exists and shutting down this ExecutorService may manipulate threads that the caller is not permitted to modify because it does not hold `RuntimePermission``("modifyThread")`, or the security manager's `checkAccess` method denies access.

### isShutdown

    public boolean isShutdown()

  Returns `true` if this executor has been shut down.

  Specified by:
    `isShutdown` in interface `java.util.concurrent.ExecutorService`
  Returns:
    `true` if this executor has been shut down

### isTerminated

    public boolean isTerminated()

  Returns `true` if all tasks have completed following shut down. Note that `isTerminated` is never `true` unless either `shutdown` or `shutdownNow` was called first.

  Specified by:
    `isTerminated` in interface `java.util.concurrent.ExecutorService`
  Returns:
    `true` if all tasks have completed following shut down

### awaitTermination

    public boolean awaitTermination(long timeout,
                                    java.util.concurrent.TimeUnit unit)
                             throws java.lang.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.

  Specified by:
    `awaitTermination` in interface `java.util.concurrent.ExecutorService`
  Parameters:
    `timeout` - the maximum time to wait
    `unit` - the time unit of the timeout argument
  Returns:
    `true` if this executor terminated and `false` if the timeout elapsed before termination
  Throws:
    `java.lang.InterruptedException` - if interrupted while waiting

### submit

    public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.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.

  If you would like to immediately block waiting for a task, you can use constructions of the form `result = exec.submit(aCallable).get();`

  Note: The `Executors` class includes a set of methods that can convert some other common closure-like objects, for example, `PrivilegedAction` to `Callable` form so they can be submitted.

  Specified by:
    `submit` in interface `java.util.concurrent.ExecutorService`
  Parameters:
    `task` - the task to submit
  Returns:
    a Future representing pending completion of the task
  Throws:
    `java.util.concurrent.RejectedExecutionException` - if the task cannot be scheduled for execution
    `java.lang.NullPointerException` - if the task is null

### submit

    public <T> java.util.concurrent.Future<T> submit(java.lang.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.

  Specified by:
    `submit` in interface `java.util.concurrent.ExecutorService`
  Parameters:
    `task` - the task to submit
    `result` - the result to return
  Returns:
    a Future representing pending completion of the task
  Throws:
    `java.util.concurrent.RejectedExecutionException` - if the task cannot be scheduled for execution
    `java.lang.NullPointerException` - if the task is null

### submit

    public java.util.concurrent.Future<?> submit(java.lang.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.

  Specified by:
    `submit` in interface `java.util.concurrent.ExecutorService`
  Parameters:
    `task` - the task to submit
  Returns:
    a Future representing pending completion of the task
  Throws:
    `java.util.concurrent.RejectedExecutionException` - if the task cannot be scheduled for execution
    `java.lang.NullPointerException` - if the task is null

### invokeAll

    public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
                                                             throws java.lang.InterruptedException

  Executes the given tasks, returning a list of Futures holding their status and results when all complete. `Future.isDone()` is `true` for each element of the returned list. Note that a completed task could have terminated either normally or by throwing an exception. The results of this method are undefined if the given collection is modified while this operation is in progress.

  Specified by:
    `invokeAll` in interface `java.util.concurrent.ExecutorService`
  Parameters:
    `tasks` - the collection of tasks
  Returns:
    A list of Futures representing the tasks, in the same sequential order as produced by the iterator for the given task list, each of which has completed.
  Throws:
    `java.lang.InterruptedException` - if interrupted while waiting, in which case unfinished tasks are cancelled.
    `java.lang.NullPointerException` - if tasks or any of its elements are `null`
    `java.util.concurrent.RejectedExecutionException` - if any task cannot be scheduled for execution

### invokeAll

    public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
                                                                        long timeout,
                                                                        java.util.concurrent.TimeUnit unit)
                                                             throws java.lang.InterruptedException

  Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first. `Future.isDone()` is `true` for each element of the returned list. Upon return, tasks that have not completed are cancelled. Note that a completed task could have terminated either normally or by throwing an exception. The results of this method are undefined if the given collection is modified while this operation is in progress.

  Specified by:
    `invokeAll` in interface `java.util.concurrent.ExecutorService`
  Parameters:
    `tasks` - the collection of tasks
    `timeout` - the maximum time to wait
    `unit` - the time unit of the timeout argument
  Returns:
    a list of Futures representing the tasks, in the same sequential order as produced by the iterator for the given task list. If the operation did not time out, each task will have completed. If it did time out, some of these tasks will not have completed.
  Throws:
    `java.lang.InterruptedException` - if interrupted while waiting, in which case unfinished tasks are cancelled
    `java.lang.NullPointerException` - if tasks, any of its elements, or unit are `null`
    `java.util.concurrent.RejectedExecutionException` - if any task cannot be scheduled for execution

### invokeAny

    public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
                throws java.lang.InterruptedException,
                       java.util.concurrent.ExecutionException

  Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do. Upon normal or exceptional return, tasks that have not completed are cancelled. The results of this method are undefined if the given collection is modified while this operation is in progress.

  Specified by:
    `invokeAny` in interface `java.util.concurrent.ExecutorService`
  Parameters:
    `tasks` - the collection of tasks
  Returns:
    the result returned by one of the tasks
  Throws:
    `java.lang.InterruptedException` - if interrupted while waiting
    `java.lang.NullPointerException` - if tasks or any of its elements are `null`
    `java.lang.IllegalArgumentException` - if tasks is empty
    `java.util.concurrent.ExecutionException` - if no task successfully completes
    `java.util.concurrent.RejectedExecutionException` - if tasks cannot be scheduled for execution

### invokeAny

    public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
                           long timeout,
                           java.util.concurrent.TimeUnit unit)
                throws java.lang.InterruptedException,
                       java.util.concurrent.ExecutionException,
                       java.util.concurrent.TimeoutException

  Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do before the given timeout elapses. Upon normal or exceptional return, tasks that have not completed are cancelled. The results of this method are undefined if the given collection is modified while this operation is in progress.

  Specified by:
    `invokeAny` in interface `java.util.concurrent.ExecutorService`
  Parameters:
    `tasks` - the collection of tasks
    `timeout` - the maximum time to wait
    `unit` - the time unit of the timeout argument
  Returns:
    the result returned by one of the tasks.
  Throws:
    `java.lang.InterruptedException` - if interrupted while waiting
    `java.lang.NullPointerException` - if tasks, any of its elements, or unit are `null`
    `java.util.concurrent.TimeoutException` - if the given timeout elapses before any task successfully completes
    `java.util.concurrent.ExecutionException` - if no task successfully completes
    `java.util.concurrent.RejectedExecutionException` - if tasks cannot be scheduled for execution

Copyright © 2010 The Apache Software Foundation