I have the following code snippet:
Alert alert;
String resultado;
resultado = "incompleto";
CompletableFuture <String> futureSupplyAsync = CompletableFuture.supplyAsync(() -> {
Future <String> future = executor.submit(new MiMetodo());
try {
resultado = future.get();
} catch (Exception ex) {
resultado = "incompleto";
}
return resultado;
}, executor);
futureSupplyAsync.whenCompleteAsync((s, e) -> {
executor.shutdown();
if (resultado == "completo") {
System.out.println("completo todo ok");
alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Notificación");
alert.setHeaderText(null);
alert.setContentText("Finalizo el proceso correctamente");
alert.showAndWait();
} else {
System.out.println("paso un error");
alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Atencion");
alert.setHeaderText("Hubo un error al procesar informacion.");
alert.setContentText("Hubo un error");
alert.showAndWait();
}
});
The code works, when it evaluates resultado
of true
, and by console it is "complete all ok", but the alert does not show it.
What could be happening to my code?