接口 IExecutor

所有超级接口:
Executor
所有已知实现类:
ImmediateExecutor

public interface IExecutor extends Executor
IExecutorExecutor的基础上增加了调度选项。

该接口需要保持较高的抽象,因此将submit之类的方法下沉到子接口。如果需要获取任务结果, 可通过ExecutorUtils.submitFunc(Executor, Callable)这类工具方法实现。

作者:
wjybxx date - 2024/1/9
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    execute(Runnable command)
    在将来的某个时间执行给定的命令。
    default void
    execute(Runnable command, int options)
    在将来的某个时间执行给定的命令。
  • 方法详细资料

    • execute

      void execute(Runnable command)
      在将来的某个时间执行给定的命令。 命令可以在新线程中执行,也可以在池线程中执行,或者在调用线程中执行,这由Executor实现决定。 Executor.execute(Runnable)
      指定者:
      execute 在接口中 Executor
      参数:
      command - 要执行的任务,注意ITask类型
      抛出:
      NullPointerException - 如果任务为null
      RejectedExecutionException - 如果Executor已开始关闭
    • execute

      default void execute(Runnable command, int options)
      在将来的某个时间执行给定的命令。 命令可以在新线程中执行,也可以在池线程中执行,或者在调用线程中执行,这由Executor实现决定。 Executor.execute(Runnable)

      任务的调度特征值 1.Executor需要感知用户任务的一些属性,以实现更好的管理。 2.选项可参考TaskOptions。 3.该接口不应该测试任务的类型,应当以参数的options为准。

      参数:
      command - 要执行的任务
      options - 任务的调度特征值,见TaskOptions
      抛出:
      NullPointerException - 如果任务为null
      RejectedExecutionException - 如果Executor已开始关闭