How do you kill a Thread in Java?

前端 未结 16 2050
天命终不由人
天命终不由人 2020-11-21 05:54

How do you kill a java.lang.Thread in Java?

16条回答
  •  名媛妹妹
    2020-11-21 06:55

    The question is rather vague. If you meant “how do I write a program so that a thread stops running when I want it to”, then various other responses should be helpful. But if you meant “I have an emergency with a server I cannot restart right now and I just need a particular thread to die, come what may”, then you need an intervention tool to match monitoring tools like jstack.

    For this purpose I created jkillthread. See its instructions for usage.

提交回复
热议问题