AsynchronousChannelGroup.WithCachedThreadPool(IExecutorService, Int32) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
使用给定的线程池创建异步通道组,以便根据需要创建新线程。
[Android.Runtime.Register("withCachedThreadPool", "(Ljava/util/concurrent/ExecutorService;I)Ljava/nio/channels/AsynchronousChannelGroup;", "", ApiSince=26)]
public static Java.Nio.Channels.AsynchronousChannelGroup? WithCachedThreadPool(Java.Util.Concurrent.IExecutorService? executor, int initialSize);
[<Android.Runtime.Register("withCachedThreadPool", "(Ljava/util/concurrent/ExecutorService;I)Ljava/nio/channels/AsynchronousChannelGroup;", "", ApiSince=26)>]
static member WithCachedThreadPool : Java.Util.Concurrent.IExecutorService * int -> Java.Nio.Channels.AsynchronousChannelGroup
参数
- executor
- IExecutorService
生成的组的线程池
- initialSize
- Int32
实现特定默认值的值 >=0 或负值
返回
新的异步通道组
- 属性
注解
使用给定的线程池创建异步通道组,以便根据需要创建新线程。
该 executor 参数是 ExecutorService 根据需要创建新线程,以执行提交以处理 I/O 事件的任务,并为组中异步通道上启动的操作调度完成结果。 当以前构造的线程可用时,它可能会重复使用以前构造的线程。
该initialSize参数可由实现用作 em>hint</em>,<就像它可能提交的初始任务数一样。 例如,它可用于指示等待 I/O 事件的初始线程数。
执行程序旨在由生成的异步通道组独占使用。 组的终止会导致执行程序服务有序 ExecutorService#shutdown shutdown 。 通过其他方式关闭执行程序服务会导致未指定的行为。
组是通过调用 AsynchronousChannelProvider#openAsynchronousChannelGroup(ExecutorService,int) openAsynchronousChannelGroup(ExecutorService,int) 系统范围的默认 AsynchronousChannelProvider 对象的方法创建的。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。