, , . ( , , Thread.stop() )
What makes Thread.interrupt()it better is that it only affects the thread if it is blocked / waiting / sleeping. If it works, it interrupt()just asks the thread to stop it by setting a status variable that can be requested with Thread.interrupted()orThread.isInterrupted()
This is usually the best way to allow threads to return from their method run(), rather than stopping them from outside in any way.
void run() {
while(!isInterrupted())
}
Be careful with Thread.interrupted(), though, since it clears interupt status.
source
share