Javatpoint Logo
Javatpoint Logo

Java Timer cancel() Method

The cancel() is the method of Timer class is used to stop the timer and remove the currently scheduled task.

Note: It is permissible to call this method from within a task scheduled on this timer.

Syntax

Example 1

Test it Now

Output:

working on
working on
working on
working on
working on
Task is stop

Example 2

Test it Now

Output:

working on
working on
working on
working on
working on
Task is stop
working on
Task is stop
working on
Task is stop
working on
Task is stop
working on
Task is stop
working on
Task is stop

Next TopicJava Timer




Help Others, Please Share

facebook twitter pinterest