I have started a thread on press of a toggle button. Now I want to stop that thread on pressing that toggle button again. But Thread.stop()
API has been deprecated. So, I am getting UnsupportedOperationException. I don't know how to use TimerTask as an alternative to it. Here is my sample code:
//AudioDispatcher implements a Runnable
public class AudioDispatcher implements Runnable
//This is a code to start a thread
AudioDispatcher dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(22050,1024,0);
Thread t1 = new Thread(dispatcher,"Audio Dispatcher");
t1.start();