Removing all queued tasks of an ThreadPoolExecutor

前端 未结 10 1849
日久生厌
日久生厌 2020-12-03 03:10

i have this rather simple question about the ThreadPoolExecutor. I have the following situation: I have to consume objects from a queue, create the appropiate worker tasks f

10条回答
  •  余生分开走
    2020-12-03 03:29

    As ExecutorService.shutdown() is not doing enough and ExecutorService.shutdownNow() is doing too much I guess you have to write up something in the middle: remember all your submitted tasks and remove them manually after (or before) calling shutdown().

提交回复
热议问题