Killing a thread in java android

android, deprecated, java, multithreading, thread-safety

Solution

You don't kill threads. You call Thread.interrupt(), and then react to the `interrupted` status or `InterruptedException` within the thread that's being interrupted. Or, you use a `volatile` flag. See the official documentation for background and more info.

Even better, use a thread pool / executor instead of raw threads, as suggested in comments.

Problem

I have an application where i need to call 3 methods in 3 seperate threads and kill them afterwards. According to the Javadoc i noticed that thread `stop()` and even `destroy()` has been deprecated. its like I start one thread after the other and then kill similarly one after the other. Is there a particular way to kill the threads because I cant use the deprecated methods Any help much appreciated. Thanks again

Original source