|
Re: what to do about InterruptedException inThreadPoolExecutor.awaitTermina: msg#00021java.jsr.166-concurrency
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. Cheers, David Holmes
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: what to do about InterruptedException inThreadPoolExecutor.awaitTermination, Dawid Kurzyniec |
|---|---|
| Next by Date: | Re: what to do about InterruptedException inThreadPoolExecutor.awaitTermination, Alexandru Popescu |
| Previous by Thread: | Re: what to do about InterruptedExceptioninThreadPoolExecutor.awaitTermination, Alexandru Popescu |
| Next by Thread: | Re: what to do about InterruptedException inThreadPoolExecutor.awaitTermination, Alexandru Popescu |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |