Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30484
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: shutdown executor service |
| Date | 2014-12-04 10:00 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <m5pstt$7ub$1@dont-email.me> (permalink) |
| References | <2db503bb-a8ea-478a-a623-d1ac65e6dbb7@googlegroups.com> |
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
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