类 ExecutorUtil

java.lang.Object
com.weicoder.common.thread.ExecutorUtil
直接已知子类:
T.E

public sealed class ExecutorUtil extends Object permits T.E
并发线程任务处理
作者:
WD
  • 构造器详细资料

    • ExecutorUtil

      public ExecutorUtil()
  • 方法详细资料

    • newExecute

      public static void newExecute(Runnable command)
      获得核心数为1新的缓存线程池执行线程
    • newSingle

      public static ExecutorService newSingle()
      获得核心数为1新的缓存线程池
      返回:
      缓存线程池
    • newPool

      public static ExecutorService newPool(int pool, boolean daemon)
      获得新的缓存线程池
      参数:
      pool - 线程池数量
      daemon - 是否守护线程
      返回:
      缓存线程池
    • execute

      public static void execute(Runnable command)
      使用pool缓存线程池执行线程
    • pool

      public static ExecutorService pool()
      获得线程池 此方法返回守护线程的池
      返回:
      线程池
    • pool

      public static ExecutorService pool(String name)
      获得线程池
      参数:
      name - 名称
      返回:
      线程池
    • addR

      public static void addR(Runnable task)
      添加线程Runnable
      参数:
      task - 任务
    • addC

      public static void addC(Callable<Object> task)
      添加线程Callable
      参数:
      task - 任务
    • execute

      public static void execute()
      执行列表中的任务
    • size

      public static int size()
      返回列表数量
      返回:
      列表数量
    • submit

      public static List<Object> submit()
      执行列表中的任务
      返回:
      列表
    • execute

      public static void execute(List<Runnable> tasks)
      执行任务 等待任务结束
      参数:
      tasks - 任务
    • submit

      public static <R> List<R> submit(List<Callable<R>> tasks)
      提交一个 Runnable 任务用于执行,并返回一个表示该任务的 Future
      类型参数:
      R - 泛型
      参数:
      tasks - Runnable 任务
      返回:
      表示该任务的 Future
    • submit

      public static <R> List<R> submit(List<Callable<R>> tasks, long timeout)
      提交一个 Runnable 任务用于执行,并返回一个表示该任务的 Future
      类型参数:
      R - 泛型
      参数:
      tasks - Runnable 任务
      timeout - 如果可以最多等待的时间
      返回:
      表示该任务的 Future
    • works

      public static void works(Calls.EoV<Long> call)
      使用单一线程 循环执行command
      参数:
      command - 工作线程
    • works

      public static void works(AtomicLong sequence, Calls.EoV<Long> call)
      指定新数量线程池驻留工作区 循环执行command
      参数:
      sequence - 工作序列
      call - 工作线程
    • works

      public static void works(int pool, Calls.EoV<Long> call)
      指定新数量线程池驻留工作区 循环执行command
      参数:
      pool - 线程池
      command - 工作线程
    • works

      public static void works(int pool, AtomicLong sequence, Calls.EoV<Long> call)
      指定新数量线程池驻留工作区 循环执行command
      参数:
      pool - 线程池
      sequence - 工作序列
      call - 工作线程
    • works

      public static void works(ExecutorService es, AtomicLong sequence, Calls.EoV<Long> call)
      指定线程池 循环执行command
      参数:
      es - 线程池
      sequence - 工作序列
      call - 工作线程