Class ExecutorKit

java.lang.Object
com.iohao.net.common.kit.concurrent.ExecutorKit

public class ExecutorKit extends Object
线程执行器工具
Author:
渔民小镇
date:
2021-12-20
  • Constructor Details

    • ExecutorKit

      public ExecutorKit()
  • Method Details

    • newVirtualExecutor

      public ExecutorService newVirtualExecutor(String name)
      创建虚拟线程执行器
      Parameters:
      name - name
      Returns:
      执行器
    • newVirtualExecutor

      public ExecutorService newVirtualExecutor(String name, int start)
      创建虚拟线程执行器
      Parameters:
      name - name
      start - start
      Returns:
      执行器
    • newVirtualExecutor

      public ExecutorService newVirtualExecutor(ThreadFactory factory)
      创建虚拟线程执行器
      Parameters:
      factory - factory
      Returns:
      执行器
    • newSingleThreadExecutor

      public ExecutorService newSingleThreadExecutor(String namePrefix)
      创建单个线程执行器
      Parameters:
      namePrefix - 线程名
      Returns:
      执行器
    • newSingleThreadExecutor

      public ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory)
      创建单个线程执行器
      Parameters:
      threadFactory - 线程创建工厂
      Returns:
      执行器
    • newCacheThreadPool

      public ExecutorService newCacheThreadPool(String namePrefix)
      创建线程池
      Parameters:
      namePrefix - 线程名
      Returns:
      执行器
    • newCacheThreadPool

      public ExecutorService newCacheThreadPool(ThreadFactory threadFactory)
      线程池
      Parameters:
      threadFactory - 线程创建工厂
      Returns:
      执行器
    • newFixedThreadPool

      public ExecutorService newFixedThreadPool(int corePoolSize, ThreadFactory threadFactory)
      创建固定大小线程执行器
      Parameters:
      corePoolSize - 容量
      threadFactory - 线程工厂
      Returns:
      执行器
    • newFixedThreadPool

      public ExecutorService newFixedThreadPool(int corePoolSize, String namePrefix)
      创建固定大小线程执行器
      Parameters:
      corePoolSize - 容量
      namePrefix - 线程名
      Returns:
      执行器
    • newSingleScheduled

      public ScheduledExecutorService newSingleScheduled(ThreadFactory threadFactory)
      创建单个线程调度执行器
      Parameters:
      threadFactory - 线程创建工厂
      Returns:
      调度 执行器
    • newSingleScheduled

      public ScheduledExecutorService newSingleScheduled(String namePrefix)
      创建单个线程调度执行器
      Parameters:
      namePrefix - 线程名
      Returns:
      调度 执行器
    • newScheduled

      public ScheduledExecutorService newScheduled(int corePoolSize, String namePrefix)
      创建指定数量 - 的线程调度执行器
      Parameters:
      corePoolSize - 容量
      namePrefix - 线程名
      Returns:
      指定数量的 调度 执行器
    • newScheduled

      public ScheduledExecutorService newScheduled(int corePoolSize, ThreadFactory threadFactory)
      创建指定数量 - 的线程调度执行器
      Parameters:
      corePoolSize - 容量
      threadFactory - 线程创建工厂
      Returns:
      指定数量的 调度 执行器
    • createThreadFactory

      public ThreadFactory createThreadFactory(String namePrefix)
      创建 线程工厂
          daemon 参数默认是 true
      
      Parameters:
      namePrefix - 线程名
      Returns:
      线程工厂
    • createThreadFactory

      public ThreadFactory createThreadFactory(@NonNull String namePrefix, boolean daemon)
      创建线程工厂
      Parameters:
      namePrefix - 线程名前缀
      daemon - 置是否守护线程
      Returns:
      线程工厂
    • createSigleThreadFactory

      public ThreadFactory createSigleThreadFactory(@NonNull String name)