[concurrency-interest] what to do about InterruptedException in ThreadPoolExecutor.awaitTermination

Alexandru Popescu the.mindstorm.mailinglist at gmail.com
Tue Oct 17 19:58:43 EDT 2006


Hi!

I am using a ThreadPoolExecutor to run invoke concurrently different
methods on an object. Before continuing, I am interested if the task
was finished:

My code looks something like:

[code]
exec.submitRunnable(imr);
exec.shutdown();
boolean finished= exec.awaitTermination(timeOut);
[/code]

I am trying to understand what should I do about the
InterruptedException that can be thrown from the awaitTermination
method. As I read in the JCiP, I should be doing one of:
1/ propagate it (which is not acceptable in my case)
2/ have something like Thread.currentThread().interrupt();
3/ ignore it

Currently, because I couldn't find a good answer to my question, I am
just ignoring it and it looks like things are working as expected (and
I have a couple of test covering the code). I have also tried the 2nd
option and I am getting the same results, so I am wondering if I am
safe with the 3rd option or should I do the 2nd one.

thanks in advance for all your advise,

./alex
--
.w( the_mindstorm )p.


More information about the Concurrency-interest mailing list