How to stop immediately a task which is started using an ExecutorService?

前端 未结 3 1700
伪装坚强ぢ
伪装坚强ぢ 2021-01-15 09:34

I have tried many different ways to immediately stop a task which is started using an ExecutorService, with no luck.

Future future = executorServ         


        
3条回答
  •  我在风中等你
    2021-01-15 09:56

    I think you'll find solution here. The main point is that cancel method raises InterruptedException. Please check if your thread is still running after cancellation? Are you sure that you didn't try to interrupt finished thread? Are you sure that your thread didn't fail with any other Exception? Try to set up UncaughtExceptionHandler.

提交回复
热议问题