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?
You cannot access it while intializing itself.
change your code to
 final Timer fgf = new Timer() {
            @Override
            public void run() {
                  cancel();
                  System.out.println();
            }
        };
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With