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


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

Re: shutdown executor service

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.datemas.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: shutdown executor service
Date Thu, 04 Dec 2014 10:00:27 -0500
Organization A noiseless patient Spider
Lines 35
Message-ID <m5pstt$7ub$1@dont-email.me> (permalink)
References <2db503bb-a8ea-478a-a623-d1ac65e6dbb7@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Thu, 4 Dec 2014 15:00:13 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="bd4e1cba8d8592bec5d5ed9e4537fbfd"; logging-data="8139"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gfnqlFaN05n1VLV5RlnPF"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0
In-Reply-To <2db503bb-a8ea-478a-a623-d1ac65e6dbb7@googlegroups.com>
Cancel-Lock sha1:5O4E8C+Sd65+NQ9Zilj1kK3WdXo=
Xref csiph.com comp.lang.java.programmer:30484

Show key headers only | View raw


On 12/4/2014 9:42 AM, mike wrote:
> Hi,
>
> I found the following code in our code base in the same class.
>
>
> private final ExecutorService executor = Executors.newCachedThreadPool();
>
> List<Future<T>> startExcuting() {
>          try {
>              return executor.invokeAll(Lists.newArrayList(tasks));
>          } catch (InterruptedException e) {
>              throw new AppException("startExcuting interrupted", e);
>          } finally {
>              tasks.clear();
>
>
>          }
>      }
>
>
> My question is: Should we not have  executor.shutdown(); or threads might live longer. Is that correct?

     This kind of ExecutorService will terminate idle threads after
sixty seconds, so although the threads might live "longer" they will
not live "forever."

     However: Is startExcuting [sic] called once only, or more than
once (presumably with different sets of tasks)?  If you shut it down
after the first use, you will not be able to use it again.  So, it
depends on what your program wants to do ...

-- 
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM

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


Thread

shutdown executor service mike <mikaelpetterson@hotmail.com> - 2014-12-04 06:42 -0800
  Re: shutdown executor service Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-12-04 10:00 -0500

csiph-web