@@ -0,0 +1,2094 @@
+package com.bloatit.common;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.ObjectInputStream;%0Aimport java.io.ObjectOutputStream;%0Aimport java.io.OutputStream;%0Aimport java.io.Serializable;%0Aimport java.util.Date;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0Aimport java.util.Timer;%0Aimport java.util.TimerTask;%0A%0Apublic abstract class PlannedTask extends TimerTask implements Serializable %7B%0A%0A    private static final long serialVersionUID = 7423363701470187880L;%0A%0A    private static Set%3CPlannedTask%3E tasks = new HashSet%3CPlannedTask%3E();%0A%0A    private final Timer timer;%0A    private final Date runDate;%0A%0A    public PlannedTask(Date time) %7B%0A        super();%0A        this.timer = new Timer();%0A        this.runDate = time;%0A        PlannedTask.tasks.add(this);%0A    %7D%0A%0A    @Override%0A    public void run() %7B%0A        doRun();%0A        tasks.remove(this);%0A    %7D%0A%0A    public abstract void doRun();%0A%0A    // /**%0A    // * @see java.util.Timer#schedule(java.util.TimerTask, long)%0A    // */%0A    // public void schedule(long delay) %7B%0A    // timer.schedule(this, delay);%0A    // %7D%0A    //%0A    // /**%0A    // * @see java.util.Timer#schedule(java.util.TimerTask, java.util.Date, long)%0A    // */%0A    // public void schedule(Date firstTime, long period) %7B%0A    // timer.schedule(this, firstTime, period);%0A    // %7D%0A%0A    /**%0A     * @see java.util.Timer#schedule(java.util.TimerTask, long, long)%0A     */%0A    public void schedule(long delay, long period) %7B%0A        timer.schedule(this, delay, period);%0A    %7D%0A%0A    public static void saveTasks(OutputStream os) throws IOException %7B%0A        ObjectOutputStream oos = new ObjectOutputStream(os);%0A        oos.writeObject(PlannedTask.tasks);%0A    %7D%0A%0A    @SuppressWarnings(%22unchecked%22)%0A    public static void loadTasks(InputStream is) throws IOException, ClassNotFoundException %7B%0A        ObjectInputStream ois = new ObjectInputStream(is);%0A        PlannedTask.tasks = (Set%3CPlannedTask%3E) ois.readObject();%0A%0A        // Relaunch the timers.%0A        for (PlannedTask task : PlannedTask.tasks) %7B%0A            task.timer.schedule(task, task.runDate);%0A        %7D%0A    %7D%0A%0A%7D%0A

add a class for tasks to do at a time