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
You don’t kill threads. You call Thread.interrupt(), and then react to the
interruptedstatus orInterruptedExceptionwithin the thread that’s being interrupted. Or, you use avolatileflag. See the official documentation for background and more info.Even better, use a thread pool / executor instead of raw threads, as suggested in comments.