0

in a spring application.

Have a call like this:

result = myCompletionService.take().get();

myCompletionService is type os CompletionService. By design, the thread will do some calculation and finish and exit. So, when spring shutdown, this call will get interruptionException and breaks the thread, which is not what I want. What I want is to let the thread run until finish. Then pass along this ShutDown signal. How can I do this?

BufBills
  • 8,005
  • 12
  • 48
  • 90
  • 1
    Your code should react to interruptions by stopping execution as soon as possible. If as soon as possible means "as soon as I have finished the coputation", then so be it. A thread computing stuff won't throw an InterruptedException, unless it waits or sleeps. And even then, it's supposed to catch it. It's unclear what the problem is without seeing some code reproducing the problem. – JB Nizet Sep 11 '15 at 21:21
  • if you can specify the thread factory, you may try overriding `Thread.interrupt()` or `Thread.isInterrupted()` and see if you could block interruption. – ZhongYu Sep 11 '15 at 21:38

0 Answers0