zoukankan      html  css  js  c++  java
  • Java基础之-ExecutorService

    翻译javadoc系列文章之:ExecutorService

    /**

     * An {@link Executor} that provides methods to manage termination and

     * methods that can produce a {@link Future} for tracking progress of

     * one or more asynchronous tasks.

     *

     * <p> An <tt>ExecutorService</tt> can be shut down, which will cause

     * it to reject new tasks.  Two different methods are provided for

     * shutting down an <tt>ExecutorService</tt>. The {@link #shutdown}

     * method will allow previously submitted tasks to execute before

     * terminating, while the {@link #shutdownNow} method prevents waiting

     * tasks from starting and attempts to stop currently executing tasks.

     * Upon termination, an executor has no tasks actively executing, no

     * tasks awaiting execution, and no new tasks can be submitted.  An

     * unused <tt>ExecutorService</tt> should be shut down to allow

     * reclamation of its resources.

     *

     * <p> Method <tt>submit</tt> extends base method {@link

     * Executor#execute} by creating and returning a {@link Future} that

     * can be used to cancel execution and/or wait for completion.

     * Methods <tt>invokeAny</tt> and <tt>invokeAll</tt> perform the most

     * commonly useful forms of bulk execution, executing a collection of

     * tasks and then waiting for at least one, or all, to

     * complete. (Class {@link ExecutorCompletionService} can be used to

     * write customized variants of these methods.)

     *

     * <p>The {@link Executors} class provides factory methods for the

     * executor services provided in this package.

     

    ExecutorService 接口是一个提供管理终止(termination)和能够生成跟踪一个或多个异步任务进程结果的方法的接口。

    介绍ExecutorService接口的功能:

      1:提供管理终止功能(拒绝新任务进入功能);

      2:提供方法来生成能够追踪一个或多个任务执行结果的Future;

     

    一个ExecutorService可以被关闭,即使其拒绝接受新的任务。

    它提供了两种不同的方法来关闭一个ExecutorService。

    方法1(shutdown方法):允许之前已经提交的任务继续执行到结束。

    方法2(shutdownNow方法):会阻止等待开始的

     

    已经有人翻译了:http://josh-persistence.iteye.com/blog/2145120

    可以参考一下;

    期待成为寂寞高手的武林老白
  • 相关阅读:
    javascript一个重要知识点:事件。
    null和undifned的区别
    javascript中常用数组方法详细讲解
    在网站中数据缓存的重要性
    谈谈我对闭包知识的深刻理解
    FormData上传文件(不是所有的浏览器都支持)
    iframe+form表单提交数据
    伪AJAX
    ajax之发送post请求
    AJAX之发送GET请求
  • 原文地址:https://www.cnblogs.com/aquariusm/p/5808781.html
Copyright © 2011-2022 走看看