Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: v_borchert@despammed.com (Volker Borchert) Newsgroups: comp.lang.java.programmer Subject: Re: ExecutorService.shutdown ambiguity Date: 18 Mar 2016 20:20:59 GMT Organization: Private site at Eddersheim, Germany Lines: 34 Distribution: world Message-ID: References: <02moebljqki662mrgr8f6ga85uhj2lt14s@4ax.com> X-Trace: individual.net qPKFoQGFHuXlTuftvCt+2Qpt/dAe+zoZDT0Sdj6w6M+ZJyIaHn Cancel-Lock: sha1:Tg//SiDWamvDA7qUTvxf+ioTs8k= Xref: csiph.com comp.lang.java.programmer:34018 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? What happens to a task that is > executing? > > * 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(); I'd expect: They will be executed normally. Therefore, you shouldn't do anything really drastic like System.exit() until awaitTermination() has returned. -- "I'm a doctor, not a mechanic." Dr Leonard McCoy "I'm a mechanic, not a doctor." Volker Borchert