Well I am currently studying JavaFX and as a total beginner(but not in Java) I started reading the official tutorials in Java and I’m currently studying Concurrency in JavaFX. and I tried to create my first JavaFx Task Object and start it. This what I have tried so far
Task<Integer> task = new Task<Integer>(){
@Override protected Integer call() throws Exception{
int iterations;
for(iterations = 0; iterations < 10000; iterations++){
if(isCancelled()){
break;
}
System.out.println("Iteration " + iterations);
Thread.sleep(3000);
}
return iterations;
}
};
//start the background task
Thread th = new Thread(task);
th.setDaemon(true);
System.out.println("Starting background task...");
th.start();
System.out.println("Background task started...");
but the task doesn’t start. I don’t see any messages in my console. Is there something I missed?
Tasks are meant to be run in the context of a JavaFX application, like in the example below