Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30356

language lawyer request for ExecutorService

From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.programmer
Subject language lawyer request for ExecutorService
Date 2014-11-15 03:53 -0800
Organization Canadian Mind Products
Message-ID <fbfe6atfghnodror7je0hhrudh1utt0v0j@4ax.com> (permalink)

Show all headers | View raw


public interface ExecutorService extends Executor {

    /**
     * Initiates an orderly shutdown in which previously submitted
     * tasks are executed, but no new tasks will be accepted.
     * Invocation has no additional effect if already shut down.
     *
     * <p>This method does not wait for previously submitted tasks to
     * complete execution.  Use {@link #awaitTermination
awaitTermination}
     * to do that.

     */
    void shutdown();


 /**
     * Blocks until all tasks have completed execution after a
shutdown
     * request, or the timeout occurs, or the current thread is
     * interrupted, whichever happens first.
     *
     * @param timeout the maximum time to wait
     * @param unit the time unit of the timeout argument
     * @return {@code true} if this executor terminated and
     *         {@code false} if the timeout elapsed before termination
     * @throws InterruptedException if interrupted while waiting
     */
    boolean awaitTermination(long timeout, TimeUnit unit)
        throws InterruptedException;

------------------

I cannot make sense of the above.  Does shutdown finish previously
submitted tasks or not. The docs seem self-contradictory. By
experiment it seems not to.

To use awaitTermination, am I supposed to call shutdown first?  But if
I did that, it would throw away all my pending work. What gives?

I just want to shut down normally completing all queued work.

-- 
Roedy Green Canadian Mind Products http://mindprod.com
Software gets slower faster than hardware gets faster.
~ Niklaus Wirth (born: 1934-02-15 age: 80) Wirth’s Law

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

language lawyer request for ExecutorService Roedy Green <see_website@mindprod.com.invalid> - 2014-11-15 03:53 -0800
  Re: language lawyer request for ExecutorService Roedy Green <see_website@mindprod.com.invalid> - 2014-11-15 04:04 -0800
    Re: language lawyer request for ExecutorService Sebastian <news@seyweiler.dyndns.org> - 2014-11-25 22:59 +0100
  Re: language lawyer request for ExecutorService Leif Roar Moldskred <leifm@huldreskog.localdomain> - 2014-11-15 06:11 -0600

csiph-web