JDK 在 1.3 的时候引入了Timer数据结构用于实现定时任务。Timer的实现思路比较简单,其内部有两个主要属性:
TaskQueue:定时任务抽象类TimeTask的列表。
TimerThread:用于执行定时任务的线程。
private final TaskQueue queue = new TaskQueue();
private final TimerThread thread = n