How do you kill a Thread in Java?

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

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

16条回答
  •  旧巷少年郎
    2020-11-21 06:40

    Generally you don't..

    You ask it to interrupt whatever it is doing using Thread.interrupt() (javadoc link)

    A good explanation of why is in the javadoc here (java technote link)

提交回复
热议问题