I am trying to shift a process in another thread and the process is completed successfully, but unable to open a notification popup from a different thread to a UI. The log in run method with here message is displayed. But notification is not showing up.
`public class CreateSnapshotView extends VerticalLayout {
private void testView(CreateSnapshot snapshot) {
Dialog dialog = new Dialog(new Label("Open Moves for ");
dialog.add(new CreateSnapshotConfirmOpenMovesView(snapshot, new CreateSnapshotConfirmOpenMovesView.Callback() {
@Override
public void yes(CreateSnapshot snapshot) {
User user = (User) UI.getCurrent().getSession().getAttribute("user");
UI ui = UI.getCurrent();
TestService testService = new TestService(snapshot,user,ui);
Thread thread = new Thread(testService);
thread.start();
dialog.close();
}
}));
dialog.setWidth("500px");
dialog.setCloseOnOutsideClick(false);
dialog.open();
}
public class TestService implements Runnable {
private User user;
private CreateSnapshot snapshot;
private DalResponse response;
private final UI ui;
public TestService(CreateSnapshot snapshot, User user, UI ui){
this.snapshot = snapshot;
this.user = user;
this.ui = ui;
}
@Override
public void run() {
DalResponse response = AppView.cycleCountService.deleteCreateSnapshot(user, snapshot);
if (response.isSuccess()) {
log.info("UI test:" + ui);
log.info("here");
ui.access(() -> Notification.show("Completed"));
}
}
}`