Graceful shutdown of threads and executor

前端 未结 5 1508
一个人的身影
一个人的身影 2020-11-29 18:42

The following piece of code tries to accompolish this.

The code loops forever and checks if there are any pending requests to be processed. If there is any, it creat

5条回答
  •  迷失自我
    2020-11-29 19:21

    Since adding a shutdown hook to explicitly call shutdown() didn't work for me, I found an easy solution in Google's Guava: com.google.common.util.concurrent.MoreExecutors.getExitingExecutorService.

提交回复
热议问题