Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Protected Ctors](https://developer.android.com/reference/java/nio/channels/spi/AsynchronousChannelProvider#proctors) \| [Methods](https://developer.android.com/reference/java/nio/channels/spi/AsynchronousChannelProvider#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/nio/channels/spi/AsynchronousChannelProvider#inhmethods)

# AsynchronousChannelProvider

` public abstract class AsynchronousChannelProvider `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.nio.channels.spi.AsynchronousChannelProvider |

<br />

*** ** * ** ***

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://developer.android.com/reference/java/nio/channels/spi/AsynchronousChannelProvider#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 />

## Summary

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/java/nio/channels/spi/AsynchronousChannelProvider#AsynchronousChannelProvider()() ` Initializes a new instance of this class. |

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

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Protected constructors

### AsynchronousChannelProvider

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected AsynchronousChannelProvider ()
```

Initializes a new instance of this class.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` | If a security manager has been installed and it denies `https://developer.android.com/reference/java/lang/RuntimePermission``("asynchronousChannelProvider")` |

## Public methods

### openAsynchronousChannelGroup

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract AsynchronousChannelGroup openAsynchronousChannelGroup (int nThreads, 
                ThreadFactory threadFactory)
```

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

<br />

| Parameters ||
|---|---|
| `nThreads` | `int`: The number of threads in the pool <br /> |
| `threadFactory` | `ThreadFactory`: The factory to use when creating new threads <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/nio/channels/AsynchronousChannelGroup` | A new asynchronous channel group <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | If an I/O error occurs |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If `nThreads <= 0` |

**See also:**

- `https://developer.android.com/reference/java/nio/channels/AsynchronousChannelGroup#withFixedThreadPool(int,%20java.util.concurrent.ThreadFactory)`

### openAsynchronousChannelGroup

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract AsynchronousChannelGroup openAsynchronousChannelGroup (ExecutorService executor, 
                int initialSize)
```

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

<br />

| Parameters ||
|---|---|
| `executor` | `ExecutorService`: The thread pool <br /> |
| `initialSize` | `int`: A value `>=0` or a negative value for implementation specific default <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/nio/channels/AsynchronousChannelGroup` | A new asynchronous channel group <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | If an I/O error occurs |

**See also:**

- `https://developer.android.com/reference/java/nio/channels/AsynchronousChannelGroup#withCachedThreadPool(java.util.concurrent.ExecutorService,%20int)`

### openAsynchronousServerSocketChannel

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract AsynchronousServerSocketChannel openAsynchronousServerSocketChannel (AsynchronousChannelGroup group)
```

Opens an asynchronous server-socket channel.

<br />

| Parameters ||
|---|---|
| `group` | `AsynchronousChannelGroup`: The group to which the channel is bound, or `null` to bind to the default group <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/nio/channels/AsynchronousServerSocketChannel` | The new channel <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | If an I/O error occurs |
| `https://developer.android.com/reference/java/nio/channels/IllegalChannelGroupException` | If the provider that created the group differs from this provider |
| `https://developer.android.com/reference/java/nio/channels/ShutdownChannelGroupException` | The group is shutdown |

### openAsynchronousSocketChannel

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract AsynchronousSocketChannel openAsynchronousSocketChannel (AsynchronousChannelGroup group)
```

Opens an asynchronous socket channel.

<br />

| Parameters ||
|---|---|
| `group` | `AsynchronousChannelGroup`: The group to which the channel is bound, or `null` to bind to the default group <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/nio/channels/AsynchronousSocketChannel` | The new channel <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | If an I/O error occurs |
| `https://developer.android.com/reference/java/nio/channels/IllegalChannelGroupException` | If the provider that created the group differs from this provider |
| `https://developer.android.com/reference/java/nio/channels/ShutdownChannelGroupException` | The group is shutdown |

### provider

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static AsynchronousChannelProvider 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 />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/nio/channels/spi/AsynchronousChannelProvider` | The system-wide default AsynchronousChannel provider <br /> |