I want to do some long running task on a button click, if user click again on that button current task forcefully stopped and will do next task ?
You have to keep checking a flag in your run method. This flag can be set to false when you want the thread to cancel. The next time your run method checks for this flag, since its false hence it exits the thread. May be you want to use a ThreadPoolExecutor?
1.4m articles
1.4m replys
5 comments
57.0k users