I am trying to return a String from a FX Task.
Expected output: true,testABC.
Real output: true,null.
The call to the task:
public static void main(String[] args) {
ExecutorService pool = Executors.newCachedThreadPool();
Future<String> my_String = (Future<String>) pool.submit(new my_task());
try {
Thread.sleep(500);
System.out.println(my_String.isDone());
System.out.println(my_String.get());//gettings the String from the future
} catch (InterruptedException | ExecutionException ex) {
Logger.getLogger(Return_test.class.getName()).log(Level.SEVERE, null, ex);
}}
The task:
public class my_task extends Task<String>{
@Override
protected String call() throws Exception {
String tempString = "testABC";
return tempString;
}}