import java.util.Timer;
import java.util.TimerTask;
public class TimerCheck
{
Timer t = null;
TimerCheck tc;
public void main() {
tc = new TimerCheck();
tc.t = new Timer();
tc.t.schedule(new TimerCheck().new demo(), 5000);
System.out.println("In main check");
//tc.t.cancel();
}
public void hello(){
System.out.println("its working");
//tc.t.cancel();
}
public static void main(
String args[]){
new TimerCheck().main();
}
class demo extends TimerTask{
public void run(){
hello();
}
}
}
Hi the above program works fine but the Timer
thread is not stopped.
how can i call cancel() method to close the thread.....