*
The moose likes Java in General and the fly likes TimerTask cancel() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "TimerTask cancel()" Watch "TimerTask cancel()" New topic
Author

TimerTask cancel()

Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
TimerTask has a cancel() method. If I have a repeated run schedule, this call forces the next scheduled run not to happen. But does it kill the thread ?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18498
    
  40

Originally posted by Raj Ohadi:
TimerTask has a cancel() method. If I have a repeated run schedule, this call forces the next scheduled run not to happen. But does it kill the thread ?


No, it does not kill the thread. If you want to do that, you need to call the cancel() method of the Timer itself.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
 
subject: TimerTask cancel()
 
Similar Threads
Timer IllegalStateException
TimerTask.cancel() not killing tasks in the webcontainer
Help needed with java.util.Timer
Question about Unreferenced
stopping Timer after certain number of actions