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

Alexandru Popescu the.mindstorm.mailinglist at gmail.com
Tue Oct 17 20:38:25 EDT 2006


On 10/18/06, David Holmes <dcholmes at optusnet.com.au> wrote:
> Alex,
>
> > 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
>
> So the difference between #2 and #3 in practice is what else the thread
> executing the above code does. In general you should always do #2 - it is
> safe and correct no matter what thread does. #3 can be correct if the thread
> does nothing else after the above code, but if you/someone changes that
> later then they need to remember to convert to #2 if needed. So stick with
> #2 as a general rule.
>

Considering my previous answer to  Dawid, it looks like at least I got
this one right.

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

> Cheers,
> David Holmes
>
>


More information about the Concurrency-interest mailing list