How to stop the task scheduled in java.util.Timer class

前端 未结 5 2009
走了就别回头了
走了就别回头了 2020-11-27 12:44

I am using java.util.Timer class and I am using its schedule method to perform some task, but after executing it for 6 times I have to stop its task.

How

5条回答
  •  时光取名叫无心
    2020-11-27 13:24

    timer.cancel();  //Terminates this timer,discarding any currently scheduled tasks.
    
    timer.purge();   // Removes all cancelled tasks from this timer's task queue.
    

提交回复
热议问题