jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Timer Thread is not closed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Timer Thread is not closed" Watch "Timer Thread is not closed" New topic

Timer Thread is not closed

Lalit mishra
Ranch Hand

Joined: Sep 01, 2005
Posts: 100
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");
public void hello(){

System.out.println("its working");
public static void main(String args[]){
new TimerCheck().main();
class demo extends TimerTask{
public void run(){


Hi the above program works fine but the Timer thread is not stopped.
how can i call cancel() method to close the thread.....
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Hi the above program works fine but the Timer thread is not stopped.

Why do you think so ?

[My Blog]
All roads lead to JavaRanch
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
The first thing that pops up in my mind is: why are you creating TimerCheck objects in 3 different places? Shouldn't a single one be sufficient?
I agree. Here's the link: http://aspose.com/file-tools
subject: Timer Thread is not closed
It's not a secret anymore!