I would like to clarify something about TimerTask. When you have the code below:
timer.schedule(task, 60000);
where the task is scheduled to ru
I don't know why your code returns false
.
The following code prints true
.
import java.util.Timer;
import java.util.TimerTask;
public class Test {
public static void main(String[] args) {
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
System.out.println("hi");
}
};
timer.schedule(task, 60000);
System.out.println(task.cancel());
}
}
If the last println
is commented, the program prints hi
.