You must interrupt the flow, which is a gentle way of asking him to stop.
Shameless copy:
final Thread thread = new Thread(someRunnable); thread.start();
Instead of stop() calling interrupt() :
thread.interrupt();
And handle the interrupt manually in the thread:
while(!Thread.currentThread().isInterrupted()){ try{ Thread.sleep(10); } catch(InterruptedException e){ Thread.currentThread().interrupt(); }
source share