语言

AsynchronousChannelGroup.WithThreadPool(IExecutorService) 方法

定义

创建具有给定线程池的异步通道组。

[Android.Runtime.Register("withThreadPool", "(Ljava/util/concurrent/ExecutorService;)Ljava/nio/channels/AsynchronousChannelGroup;", "", ApiSince=26)]
public static Java.Nio.Channels.AsynchronousChannelGroup? WithThreadPool(Java.Util.Concurrent.IExecutorService? executor);
[<Android.Runtime.Register("withThreadPool", "(Ljava/util/concurrent/ExecutorService;)Ljava/nio/channels/AsynchronousChannelGroup;", "", ApiSince=26)>]
static member WithThreadPool : Java.Util.Concurrent.IExecutorService -> Java.Nio.Channels.AsynchronousChannelGroup

参数

executor
IExecutorService

生成的组的线程池

返回

新的异步通道组

特性

注解

创建具有给定线程池的异步通道组。

该 executor 参数执行 ExecutorService 提交的任务,以调度在组中异步通道上启动的操作的完成结果。

配置执行程序服务时应小心。 它应支持 <提交的任务的 em>直接交接</em> 或 <em>无绑定队列</em> ,并且调用该方法的线程绝不应直接调用 ExecutorService#execute execute 任务。 实现可能强制实施其他约束。

执行程序旨在由生成的异步通道组独占使用。 组的终止会导致执行程序服务有序 ExecutorService#shutdown shutdown 。 通过其他方式关闭执行程序服务会导致未指定的行为。

通过调用 AsynchronousChannelProvider#openAsynchronousChannelGroup(ExecutorService,int) openAsynchronousChannelGroup(ExecutorService,int) 系统范围的默认 AsynchronousChannelProvider 对象的方法和一个 initialSize 值 0来创建组。

适用于 . 的 java.nio.channels.AsynchronousChannelGroup.withThreadPool(java.util.concurrent.ExecutorService)Java 文档

本页的某些部分是根据 Android 开放源代码项目创建和共享的工作进行的修改,并根据 Creative Commons 2.5 属性许可证中所述的术语使用。

适用于