接口的使用
java.util.concurrent.ExecutorService
使用 ExecutorService 的包
包
描述
定义通道,它表示与能够执行 I/O 操作的实体的连接,例如文件和套接字;定义选择器,用于多路复用、非阻塞 I/O 操作。
java.nio.channels 包的服务提供商类。
java.nio.file 包的服务提供商类。
通常在并发编程中有用的实用程序类。
-
ExecutorService 在 java.nio.channels 中的用法
java.nio.channels 中的方法,参数类型为 ExecutorService修饰符和类型方法描述static AsynchronousFileChannelAsynchronousFileChannel.open(Path file, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs) 打开或创建用于读取和/或写入的文件,返回异步文件通道以访问该文件。static AsynchronousChannelGroupAsynchronousChannelGroup.withCachedThreadPool(ExecutorService executor, int initialSize) 使用给定线程池创建一个异步通道组,该线程池根据需要创建新线程。static AsynchronousChannelGroupAsynchronousChannelGroup.withThreadPool(ExecutorService executor) 使用给定线程池创建异步通道组。 -
ExecutorService 在 java.nio.channels.spi 中的用法
java.nio.channels.spi 中的方法,参数类型为 ExecutorService修饰符和类型方法描述abstract AsynchronousChannelGroupAsynchronousChannelProvider.openAsynchronousChannelGroup(ExecutorService executor, int initialSize) 使用给定的线程池构造一个新的异步通道组。 -
ExecutorService 在 java.nio.file.spi 中的用法
java.nio.file.spi 中的方法,参数类型为 ExecutorService修饰符和类型方法描述FileSystemProvider.newAsynchronousFileChannel(Path path, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs) 打开或创建用于读取和/或写入的文件,返回异步文件通道以访问该文件。 -
ExecutorService 在 java.util.concurrent 中的用法
修饰符和类型类描述class提供ExecutorService执行方法的默认实现。class用于运行ForkJoinTask的ExecutorService。classThreadPoolExecutor可以额外安排命令在给定延迟后运行,或定期执行。class一个ExecutorService,它使用可能的几个池线程之一执行每个提交的任务,通常使用Executors工厂方法配置。java.util.concurrent 中返回 ExecutorService 的方法修饰符和类型方法描述static ExecutorServiceExecutors.newCachedThreadPool()创建一个线程池,该线程池根据需要创建新线程,但会在可用时重用以前构造的线程。static ExecutorServiceExecutors.newCachedThreadPool(ThreadFactory threadFactory) 创建一个线程池,该线程池根据需要创建新线程,但会在可用时重用以前构造的线程,并在需要时使用提供的 ThreadFactory 创建新线程。static ExecutorServiceExecutors.newFixedThreadPool(int nThreads) 创建一个线程池,该线程池重用固定数量的线程,这些线程在共享的无界队列中运行。static ExecutorServiceExecutors.newFixedThreadPool(int nThreads, ThreadFactory threadFactory) 创建一个线程池,该线程池重用固定数量的线程,这些线程在共享无界队列中运行,并在需要时使用提供的 ThreadFactory 创建新线程。static ExecutorServiceExecutors.newSingleThreadExecutor()创建一个 Executor,它使用单个工作线程在无界队列中运行。static ExecutorServiceExecutors.newSingleThreadExecutor(ThreadFactory threadFactory) 创建一个 Executor,它使用单个工作线程在无界队列中运行,并在需要时使用提供的 ThreadFactory 创建新线程。static ExecutorServiceExecutors.newThreadPerTaskExecutor(ThreadFactory threadFactory) 预览。创建一个执行器,为每个任务启动一个新线程。static ExecutorServiceExecutors.newVirtualThreadPerTaskExecutor()预览。创建一个执行器,为每个任务启动一个新的虚拟线程。static ExecutorServiceExecutors.newWorkStealingPool()使用 可用处理器 的数量作为其目标并行级别创建工作窃取线程池。static ExecutorServiceExecutors.newWorkStealingPool(int parallelism) 创建一个线程池,该线程池维护足够的线程以支持给定的并行度级别,并且可以使用多个队列来减少争用。static ExecutorServiceExecutors.unconfigurableExecutorService(ExecutorService executor) 返回一个对象,该对象将所有定义的ExecutorService方法委托给给定的执行程序,但不委托任何其他可以使用强制转换访问的方法。java.util.concurrent 中的方法,参数类型为 ExecutorService修饰符和类型方法描述static ExecutorServiceExecutors.unconfigurableExecutorService(ExecutorService executor) 返回一个对象,该对象将所有定义的ExecutorService方法委托给给定的执行程序,但不委托任何其他可以使用强制转换访问的方法。