The cancel() is used for two reasons:
1. Prevent a task that is already scheduled from actually running. This works if the canel() method is called prior to the task starting.
2. Stop a task that is already running. If the task has already begun, and the boolean mayInterruptIfRunning flag is false, then it lets the current task complete. If mayInterruptIfRunning is true, then it attempts to interrupt the
Thread running the task, to cause it to end. It will call the interrupt() on the task Thread. In order for it to work you task has to respond to interruption, for example by periodically checking Thread.interrupted() to see if it should end.