Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Thread question Date: Wed, 30 Nov 2011 21:04:59 -0500 Organization: A noiseless patient Spider Lines: 20 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 1 Dec 2011 02:05:03 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="HSlJAUb3pGXi3i7ZL/HoAw"; logging-data="32078"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196xvahoKpA9o1Qnb365yDn" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: Cancel-Lock: sha1:WsheZChDNBK1ld2LT2dTQ3M53nw= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10390 On 11/30/2011 8:30 AM, markspace wrote: > On 11/30/2011 4:28 AM, Eric Sosman wrote: > >> On 11/30/2011 4:31 AM, Roedy Green wrote: >>> 2. some way of knowing when the last one completed. > >> A simple counter will do it. > > > I'd recommend the simple built-in method "ExecutorService::shutdown()". > It waits until all tasks have completed. ITYM awaitTermination(), a method I hadn't noticed but which does as you say *and* has a useful timeout. shutdown(), however, does not wait: It just "initiates an orderly shutdown" and returns with the shutdown still (potentially) in progress. -- Eric Sosman esosman@ieee-dot-org.invalid