title: How to kill a java thread?
body: <p>I google the solution for killing a java thread. And there exists two solutions: </p>
  
  <ol>
  <li>set a flag</li>
  <li>using Thread.interrupt</li>
  </ol>
  
  <p>But both of them are not suitable for me. In my thread, I call a third-party api which takes a long time to complete. and I want to let the user to cancel this thread if it takes too much time.</p>
  
  <p>So how can I kill this thread ? Thanks in advance.</p>