In desktop UI toolkits there are things such java.awt.EventQueue.invokeLater (or SwingUtilites.invokeLater) that helps you to execute some Runnable asynchronically AFTER the calling thread complete. Example from javadoc for SwingUtilities class:
In the following example the invokeLater call queues
the Runnable object doHelloWorld
on the event dispatching thread and
then prints a message.
Runnable doHelloWorld = new Runnable() {
public void run() {
System.out.println("Hello World on " + Thread.currentThread());
}
};
SwingUtilities.invokeLater(doHelloWorld);
System.out.println("This might well be displayed before the other message.");
Of cource, it is possible implement similar class class in core-vaadin to execute some async Runnable after calling thread finished. To apply changes of UI that was done in his async Runnable we can use poll or push mechanism (Refresher, ICEPushAddon), becouse pending thread send the changes to client and complete, and UI changes in our Runnable is not send to client on his request. But using poll or push is overkill in case when I just want to some appending to client request in async way. There are simple way to implented this. Suppose that there are exists some class InvokeLaterExecutor that have method addInvokeLaterRunnable allowing to add Runnable. The VaadinServlet after collecting UI changes call InvokeLaterExecutor’s execute method that execute all Runnables added with addInvokeLaterRunnable method in adding order. So features that given by EventQueue.invokeLater can be obtained in vaadin. Currently I don’t see this ability in Vaadin. It will be great if vaadin team will implement this, becouse it is total simply and very useful in many cases.