Java Timer purge() Method

The purge() is the method of Timer class. It is used to cancel the tasks present in the TimerTask Chain.

Syntax

Return

This method returns the number of tasks removed from the queue.

Example 1

Output:

Task is on
Task is on
Task is on
Task is on
Task is on
Task is stop
purge value of Task:0