Reputation: 5153
I am trying to schedule a repeating timer in GWT, it will run every one milli second, poll for a certain event, if it is found satisfactory, do something and cancel the timer. I tried doing this:
final Timer t = new Timer() {
public void run() {
if (..condition is true, exit) {
t.cancel();
doSomething();
}
}
}
t.scheduleRepeating(1);
However, I get an error message like the local variable t may not have been initialized. I am putting tis piece of code in the onSuccess
clause of a RequestBuilder
callback.. How do I achieve this?
Upvotes: 4
Views: 3370
Reputation: 121998
You cannot access it while intializing itself.
change your code to
final Timer fgf = new Timer() {
@Override
public void run() {
cancel();
System.out.println();
}
};
Upvotes: 9