Vaadin Portlet in Liferay Thread Issue - Vaadin 7.2.0

Hello all,

I am trying to open a window, kick off a new thread that runs a query (while some kind of progress bar is running), and have the option of killing the thread if needed via a button. I want to be able to stop the execution on the main thread so that it is waiting for the result of the query running in the new thread.

Here is the code that created the new window:

Window sw = new Window("Receipt"); QueryRun qr = new QueryRun(this.transManager,transInfo,sw,myUi); sw.setImmediate(true); sw.setClosable(false); sw.setModal(true); sw.setContent(qr); sw.center(); sw.setHeight("250px"); sw.setWidth("350px"); myUi.addWindow(sw);Code contained in the QueryRun class: Here is the code in the window (omitting some parts):

public QueryRun(TransactionManager transManager, TransactionInfo transInfo, final Window wi, MyPortletUI mUi)
.
.
.
this.mUi_This.setPollInterval(1000);
final Thread tr = new Thread(new Loader());
tr.start();
.
.
.
.
.
class Loader extends Thread {
        @Override
        public synchronized void run() {
            try {
                // Run the query here
            } catch (Exception e) {
            }
            mUi_This.access(new Runnable() {
                @Override
                public void run() {
                    addComponent(new Label("This is the real content"));
                    mUi_This.setPollInterval(-1);
                    //wi_This.close();
                }
            });
        }

   
}

The polling aspect works correctly, the window is getting updated from the new thread. I just cannot get the main thread to wait for the new thread. I have also tried the typical Java “wait” and “notify” approach with the new thread being synchronized, but I am getting issues with when the window appears (as if it is not polling at all).

Thanks in advance!