I honestly can’t figure it out – I’ve heard that thread.stop() is not a good thing to use. It also isn’t working for me. How to get threads/handlers to stop running?
I honestly can’t figure it out – I’ve heard that thread.stop() is not a
Share
Threads should be terminated in a “polite” way. You should build in some mechanism for your thread to stop. You can have a volatile boolean parameter that is checked on every loop of your thread (assuming you have loops in there) like so:
And then you can set the boolean value to false from another thread (make sure you handle all synchronization issues though) and your thread will stop in it’s next iteration.