Vaadin Table using threads only working one way
<p>I have a class called HomeView that is used to extend a Vaadin Designer HTML class. This class has a Vaadin table that takes input from an uploaded file. So far the file uploads fine and I can split the file up into lines for testing. I was trying to use Vaadin threads to lock the session and go to the UploadFile class in which I will split up the file and add to a row in the table. I would then unlock the session, exit back to the background thread and the UI should update the table with new rows. This is not happening with the code below.</p>

<pre><code>    public void uploadSucceeded(Upload.SucceededEvent succeededEvent) {
            //upload notification for upload
            new Notification("File Uploaded Successfully",
                    Notification.Type.HUMANIZED_MESSAGE)
            .show(Page.getCurrent());
            //create new class for parsing logic
            uf = new UploadFile();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        getSession().lock();
                        uf.parseFile();
                        getSession().unlock();
                    } catch (IOException e) {
                        new Notification("Could not parse file type",
                                e.getMessage(),
                                Notification.Type.ERROR_MESSAGE)
                        .show(Page.getCurrent());
                    }
                    catch (UnsupportedOperationException e) {
                        e.printStackTrace();
                    } catch (ReadOnlyException e) {
                        e.printStackTrace();
                    }
                }
            }).start();
            //outputFile.delete();
        }
    });
</code></pre>

<p>UploadFile class</p>

<pre><code>public class UploadFile extends HomeView {

/**
 * 
 */
private static final long serialVersionUID = 839096232794540854L;

public void parseFile() throws IOException {

    //container.removeAllItems();
    BufferedReader reader = null;

    reader = new BufferedReader(new InputStreamReader(new FileInputStream(outputFile.getAbsolutePath()), StandardCharsets.UTF_8));
    String line;
    while ((line = reader.readLine()) != null)
    {
        System.out.println("before add:" + uploadTable.size());
        container = uploadTable.getContainerDataSource();
        container.addItem("row3");
        Item item2 = container.getItem("row3");
        Property property2 = item2.getItemProperty("name");
        property2.setValue("hello");
        uploadTable.setContainerDataSource(container);
        System.out.println("after add:" + uploadTable.size());

    }
    reader.close();
}
}
</code></pre>

<p>If I take the code above and just put it in place of the method call, then the table updates fine. The table is updating the row count in the background, it's just not refreshing the view. What am I missing to make the UI refresh?</p>

<pre><code>@Override
        public void uploadSucceeded(Upload.SucceededEvent succeededEvent) {
            //upload notification for upload
            new Notification("File Uploaded Successfully",
                    Notification.Type.HUMANIZED_MESSAGE)
            .show(Page.getCurrent());
            //create new class for parsing logic
            uf = new UploadFile();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        getSession().lock();

                        BufferedReader reader = null;

                        reader = new BufferedReader(new InputStreamReader(new FileInputStream(outputFile.getAbsolutePath()), StandardCharsets.UTF_8));
                        String line;
                        while ((line = reader.readLine()) != null)
                        {
                            System.out.println("before add:" + uploadTable.size());
                            container = uploadTable.getContainerDataSource();
                            container.addItem("row3");
                            Item item2 = container.getItem("row3");
                            Property property2 = item2.getItemProperty("name");
                            property2.setValue("hello");
                            uploadTable.setContainerDataSource(container);
                            System.out.println("after add:" + uploadTable.size());

                        }
                        reader.close();


                        getSession().unlock();
                    } catch (IOException e) {
                        new Notification("Could not parse file type",
                                e.getMessage(),
                                Notification.Type.ERROR_MESSAGE)
                        .show(Page.getCurrent());
                    }
                    catch (UnsupportedOperationException e) {
                        e.printStackTrace();
                    } catch (ReadOnlyException e) {
                        e.printStackTrace();
                    }
                }
            }).start();
            //outputFile.delete();
        }
    });
</code></pre>