How do I execute code in an interval?

I have a little taskbar applet that is supposed to check what tasks are close to a deadline every so often (depending on the settings). On my computer it does, but very randomly, on other computers it doesn't even execute. I thought I had it working but it appears I was wrong. This is what I'm doing:

// Deadline Warning Task Warning Timer

deadline_timer.schedule(new TimerTask(){

publicvoid run(){

OverWarn();

}

privatevoid OverWarn(){

if(current_state =="warning"){

trayIcon.displayMessage("You have a task nearing its deadline","You have at least one task that is within "+ConfigurationManager.ReadConfiguration("deadline_threshold")+" hours of when it needs to be completed. Click on this icon to see all assigned tasks.", TrayIcon.MessageType.WARNING);

}

}

}

, Integer.parseInt(ConfigurationManager.ReadConfiguration("deadline_frequency"))*100000, Integer.parseInt(ConfigurationManager.ReadConfiguration("deadline_frequency"))*100000);

Can someone help me to simply run execute some code every couple of minutes (or at least how many minutes the user decides).

Thanks much in advance.

[1804 byte] By [nehalema] at [2007-11-27 8:46:47]
# 1

It's won't work on millisecond precision, but what about something like this?

public class SomeTask implements Runnable {

public SomeTask() {

Thread t=new Thread(this);

t.start();

}

public void run() {

while (true) {

doSomething();

try {

Thread.sleep(TIME);

} catch (Exception e) {

e.printStackTrace();

}

}

}

}

keeskista at 2007-7-12 20:50:02 > top of Java-index,Java Essentials,Java Programming...