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

前端 未结 5 2028
走了就别回头了
走了就别回头了 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:12

    Either call cancel() on the Timer if that's all it's doing, or cancel() on the TimerTask if the timer itself has other tasks which you wish to continue.

提交回复
热议问题