How to kill a java thread?

前端 未结 8 1977
一个人的身影
一个人的身影 2020-12-11 08:26

I google the solution for killing a java thread. And there exists two solutions:

  1. set a flag
  2. using Thread.interrupt

But both of them ar

8条回答
  •  臣服心动
    2020-12-11 09:13

    In java.util.concurrent.FutureTask, the mechanism of cancellation by timeout is acted as throwing java.util.concurrent.TimeoutException.

    You may check out this as if there are something to be interrupted automatically by timeout.

提交回复
热议问题