Quick Answer: How Can a Thread in Android Be Stopped?
Contents How Do You Stop a Thread? Modern Ways to Suspend/Stop a Thread Are by Using a Boolean Flag and Thread. Interrupt() Method. Using a Boolean Flag: We...
Contents
How do you stop a thread?
Modern ways to suspend/stop a thread are by using a boolean flag and Thread. interrupt() method. Using a boolean flag: We can define a boolean variable which is used for stopping/killing threads say ‘exit’. Whenever we want to stop a thread, the ‘exit’ variable will be set to true.
How can a thread be killed in Android?
The method Thread. stop() is deprecated, you can use Thread. currentThread(). interrupt(); and then set thread=null .