# AsynchronousChannelProvider

public abstract class **AsynchronousChannelProvider** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
Service-provider class for asynchronous channels.

An asynchronous channel provider is a concrete subclass of this class that
has a zero-argument constructor and implements the abstract methods specified
below. A given invocation of the Java virtual machine maintains a single
system-wide default provider instance, which is returned by the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AsynchronousChannelProvider.html#provider()` method. The first invocation of that method will locate
the default provider as specified below.

All of the methods in this class are safe for use by multiple concurrent
threads.

<br />

### Protected Constructor Summary

|---|---|
|   | [AsynchronousChannelProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AsynchronousChannelProvider.html#AsynchronousChannelProvider())() Initializes a new instance of this class. |

### Public Method Summary

|---|---|
| abstract [AsynchronousChannelGroup](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannelGroup.html) | [openAsynchronousChannelGroup](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AsynchronousChannelProvider.html#openAsynchronousChannelGroup(int,%20java.util.concurrent.ThreadFactory))(int nThreads, [ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory) Constructs a new asynchronous channel group with a fixed thread pool. |
| abstract [AsynchronousChannelGroup](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannelGroup.html) | [openAsynchronousChannelGroup](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AsynchronousChannelProvider.html#openAsynchronousChannelGroup(java.util.concurrent.ExecutorService,%20int))([ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) executor, int initialSize) Constructs a new asynchronous channel group with the given thread pool. |
| abstract [AsynchronousServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousServerSocketChannel.html) | [openAsynchronousServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AsynchronousChannelProvider.html#openAsynchronousServerSocketChannel(java.nio.channels.AsynchronousChannelGroup))([AsynchronousChannelGroup](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannelGroup.html) group) Opens an asynchronous server-socket channel. |
| abstract [AsynchronousSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousSocketChannel.html) | [openAsynchronousSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AsynchronousChannelProvider.html#openAsynchronousSocketChannel(java.nio.channels.AsynchronousChannelGroup))([AsynchronousChannelGroup](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannelGroup.html) group) Opens an asynchronous socket channel. |
| static [AsynchronousChannelProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AsynchronousChannelProvider.html) | [provider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AsynchronousChannelProvider.html#provider())() Returns the system-wide default asynchronous channel provider for this invocation of the Java virtual machine. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Protected Constructors

#### protected
**AsynchronousChannelProvider**
()

Initializes a new instance of this class.

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | If a security manager has been installed and it denies `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/RuntimePermission.html`("asynchronousChannelProvider") |
|---|---|

## Public Methods

#### public abstract [AsynchronousChannelGroup](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannelGroup.html)
**openAsynchronousChannelGroup**
(int nThreads, [ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory)

Constructs a new asynchronous channel group with a fixed thread pool.

##### Parameters

| nThreads | The number of threads in the pool |
| threadFactory | The factory to use when creating new threads |
|---|---|

##### Returns

- A new asynchronous channel group

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | If `nThreads <= 0` |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If an I/O error occurs |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannelGroup.html#withFixedThreadPool(int,%20java.util.concurrent.ThreadFactory)`

#### public abstract [AsynchronousChannelGroup](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannelGroup.html)
**openAsynchronousChannelGroup**
([ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) executor, int initialSize)

Constructs a new asynchronous channel group with the given thread pool.

##### Parameters

| executor | The thread pool |
| initialSize | A value `>=0` or a negative value for implementation specific default |
|---|---|

##### Returns

- A new asynchronous channel group

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If an I/O error occurs |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannelGroup.html#withCachedThreadPool(java.util.concurrent.ExecutorService,%20int)`

#### public abstract [AsynchronousServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousServerSocketChannel.html)
**openAsynchronousServerSocketChannel**
([AsynchronousChannelGroup](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannelGroup.html) group)

Opens an asynchronous server-socket channel.

##### Parameters

| group | The group to which the channel is bound, or `null` to bind to the default group |
|---|---|

##### Returns

- The new channel

##### Throws

| [IllegalChannelGroupException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/IllegalChannelGroupException.html) | If the provider that created the group differs from this provider |
| [ShutdownChannelGroupException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ShutdownChannelGroupException.html) | The group is shutdown |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If an I/O error occurs |
|---|---|

#### public abstract [AsynchronousSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousSocketChannel.html)
**openAsynchronousSocketChannel**
([AsynchronousChannelGroup](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannelGroup.html) group)

Opens an asynchronous socket channel.

##### Parameters

| group | The group to which the channel is bound, or `null` to bind to the default group |
|---|---|

##### Returns

- The new channel

##### Throws

| [IllegalChannelGroupException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/IllegalChannelGroupException.html) | If the provider that created the group differs from this provider |
| [ShutdownChannelGroupException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ShutdownChannelGroupException.html) | The group is shutdown |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If an I/O error occurs |
|---|---|

#### public static [AsynchronousChannelProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AsynchronousChannelProvider.html)
**provider**
()

Returns the system-wide default asynchronous channel provider for this
invocation of the Java virtual machine.

The first invocation of this method locates the default provider
object as follows:

1. If the system property
   java.nio.channels.spi.AsynchronousChannelProvider is defined
   then it is taken to be the fully-qualified name of a concrete provider class.
   The class is loaded and instantiated; if this process fails then an
   unspecified error is thrown.

2. If a provider class has been installed in a jar file that is
   visible to the system class loader, and that jar file contains a
   provider-configuration file named
   java.nio.channels.spi.AsynchronousChannelProvider in the resource
   directory META-INF/services, then the first class name
   specified in that file is taken. The class is loaded and
   instantiated; if this process fails then an unspecified error is
   thrown.

3. Finally, if no provider has been specified by any of the above
   means then the system-default provider class is instantiated and the
   result is returned.

Subsequent invocations of this method return the provider that was
returned by the first invocation.

<br />

##### Returns

- The system-wide default AsynchronousChannel provider