logo       

Re: what to do about InterruptedException inThreadPoolExecutor.awaitTermina: msg#00023

java.jsr.166-concurrency

Subject: Re: what to do about InterruptedException inThreadPoolExecutor.awaitTermination

On 10/18/06, David Holmes <dcholmes@xxxxxxxxxxxxxxx> 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
>
>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise