Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: ExecutorService.shutdown ambiguity Date: Fri, 18 Mar 2016 20:52:38 -0000 (UTC) Organization: A noiseless patient Spider Lines: 34 Message-ID: References: <02moebljqki662mrgr8f6ga85uhj2lt14s@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 18 Mar 2016 20:52:38 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="e689d4a62ab06da9e54b78e64d3e802f"; logging-data="13661"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/a3pmq1TvFw+mjN+asOC1UH8t+N0BWAbs=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:2x4Vj5mYBhEVsFkqyWDF93GS4Hc= Xref: csiph.com comp.lang.java.programmer:34017 On Fri, 18 Mar 2016 12:37:13 -0700, Roedy Green wrote: > Here is the JavaDoc for ExecutorService.shutdown. > To me it is ambiguous. How do you read it? > > What happens to a task in queue? "... previously submitted tasks are executed ..." > What happens to a task that is executing? Presumably it continues executing. However ExecutorService.shutdown() returns without awaiting completion. > > * 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. > * > *

This method does not wait for previously submitted tasks to * > complete execution. Use {@link #awaitTermination > awaitTermination} > * to do that. > * > * @throws SecurityException if a security manager exists and * > shutting down this ExecutorService may manipulate * > threads that the caller is not permitted to modify * > because it does not hold {@link * > java.lang.RuntimePermission}{@code ("modifyThread")}, * or > the security manager's {@code checkAccess} method * denies > access. > */ > void shutdown();