Removing all queued tasks of an ThreadPoolExecutor

前端 未结 10 1827
日久生厌
日久生厌 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:16

    A crazy and unclean solution which might work (not real thought through or tested) would be to overwrite the interrupt() of your WorkerTasks which only in case some global value is set refuse to shutdown when interrupt() is called on them by shutdownNow().

    That should allow you to use shutdownNow() no?

提交回复
热议问题