ExecutorService that interrupts tasks after a timeout

后端 未结 9 2208
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 16:19

I\'m looking for an ExecutorService implementation that can be provided with a timeout. Tasks that are submitted to the ExecutorService are interrupted if they take longer t

9条回答
  •  忘了有多久
    2020-11-22 16:41

    Wrap the task in FutureTask and you can specify timeout for the FutureTask. Look at the example in my answer to this question,

    java native Process timeout

提交回复
热议问题