Thread-Killing.

I am working on a Java application which involves multithreading. Now, our application gets locked up and wouldn't stop when used as a windows service. The two threads in background continue to run even when we try to close the application. I was wondering how can i kill the two background threads. Any inputs will be appreciated. I can provide further details if needed.

In our application, in the main class two threads are created using Timer and are scheduled for execution after regular intervals of time. There is an Exit-handler class as well which cleans up the directory contents and in the exit-handler, the two threads(FTP and Upload) are not killed. So, typically we might need to implement some method which will kill these threads when they invoke the exit handler.We might need to use the cancel() to terminate the timer's task thread.

Any inputs will be highly appreciated.

[913 byte] By [Javaaka888a] at [2007-11-27 8:12:14]
# 1
Try initializing the Timers as daemons, i.e. use the Timer(boolean) constructor passing it true.
dwga at 2007-7-12 19:56:34 > top of Java-index,Java Essentials,Java Programming...
# 2

Thanks for your input. I tried that but when i run the application, the application stops after a while and didn抰 run after that. That could be because the threads are scheduled for execution after regular intervals separated by specific period as we are using scheduleAtFixedRate(TimerTask task, long delay,long period) method to schedule the tasks.

Javaaka888a at 2007-7-12 19:56:34 > top of Java-index,Java Essentials,Java Programming...