Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30483 > unrolled thread
| Started by | mike <mikaelpetterson@hotmail.com> |
|---|---|
| First post | 2014-12-04 06:42 -0800 |
| Last post | 2014-12-04 10:00 -0500 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.java.programmer
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
| From | mike <mikaelpetterson@hotmail.com> |
|---|---|
| Date | 2014-12-04 06:42 -0800 |
| Subject | shutdown executor service |
| Message-ID | <2db503bb-a8ea-478a-a623-d1ac65e6dbb7@googlegroups.com> |
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?
//mike
[toc] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2014-12-04 10:00 -0500 |
| Message-ID | <m5pstt$7ub$1@dont-email.me> |
| In reply to | #30483 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web