Possible Duplicate:
Timer Won't Fire Correctly
Apparently, in Java 1.6, the Timer
doesn't work like it used to, so how do I get a task to fire every 250ms (1/4 of a second)?
Possible Duplicate:
Timer Won't Fire Correctly
Apparently, in Java 1.6, the Timer
doesn't work like it used to, so how do I get a task to fire every 250ms (1/4 of a second)?
If you want to do task every 250ms even doStuff() may take more than 250ms, you should use a new thread to "doStuff"(In this case, more than one doStuff may work at a time)
updated(I tried this in win7x64, JDK 1.6 and it works)
java.util.TimerTask task = new java.util.TimerTask() {
@Override
public void run() {
System.out.println("yoo");
}
};
java.util.Timer timer = new java.util.Timer();
timer.schedule(task, java.util.Calendar.getInstance().getTime(), 250);