美文网首页
Executor Interface

Executor Interface

作者: laughPis | 来源:发表于2016-04-14 17:00 被阅读0次

    Executor Interface

    定义

    public interface Executor {
    
        /**
         * 提交一个任务,该任务会在将来的某个时间执行。这个任务会被一个新的线程执行,有可能会被一个线程池的线程执行,
         * 也有可能就被提交者本身的线程执行
         *
         * @param command the runnable task
         * @throws RejectedExecutionException if this task cannot be
         * accepted for execution.
         * @throws NullPointerException if command is null
         */
        void execute(Runnable command);
    }
    
    

    实现

    1. 立即执行任务
    class DirectExecutor implements Executor {
          public void execute(Runnable r) {
              r.run();
          }
      }
    

    相关文章

      网友评论

          本文标题:Executor Interface

          本文链接:https://www.haomeiwen.com/subject/fgiglttx.html