Stop a thread like:
new Thread ( new Runnable() {
public void run(){
if ( condition ) return; // this will stop the thread.
}
}).start();
is correct/safe?
A thread stops when it's run()
method returns. It doesn't really matter what logic is used inside run()
to decide when or how to return. Your code is perfectly correct and safe.