On the one hand, you are right - the problem cannot be caused by a separate thread, since JavaScript is single-threaded.
Callback events will certainly be handled by an event handler that starts after the current event handler (the one that builds the current object) is completed. Therefore, they will only see a fully constructed object.
On the other hand, you don't need threads at all to use the underlying problem. Here is a simple example:
final A a = new A(); final B b = new B(a);
public class A { private B b; public void setB(final B b) { this.b = b; } public void letBSaySomething() { b.saySomething(); } }
public class B { private A a; private final int some; public B(final A a) { this.a = a; a.setB(this); a.letBSaySomething(); some = 55; a.letBSaySomething(); } public void saySomething() { RootPanel.get().add(new Label("Hello " + some)); } }
The result is a conclusion
Hello 0 Hello 55
(although "some" are final). This happens both in GWT (compiled / uncompiled) and in simple Java programs.
source share