I am keen on knowing a good way to stop the thread I want to ? Please give me some suggestion . Thank you !
Using Thread.interrupt() is a perfectly acceptable way of doing this. In fact, it's probably preferrable over using a flag. The reason being that if you're in an interruptable blocking call (like Thread.sleep or using java.nio Channel operations), you'll actually be able to break out of those right away.
You can find some reasonable alternatives in this post - How to properly stop the Thread in Java?