Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9078105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:32:15+00:00 2026-06-16T19:32:15+00:00

Well I am currently studying JavaFX and as a total beginner(but not in Java)

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:32:16+00:00Added an answer on June 16, 2026 at 7:32 pm

    Tasks are meant to be run in the context of a JavaFX application, like in the example below

    import javafx.application.Application;
    import javafx.concurrent.Task;
    import javafx.stage.Stage;
    
    import java.io.IOException;
    
    public class JavaTaskClass extends Application{
    
           public static void main(String[] args) { 
             launch(args); 
           }
    
          @Override public void start(final Stage stage) throws IOException {
            //create task object
            Task<Integer> task = new Task<Integer>(){
    
              @Override
              protected Integer call() throws Exception{
                System.out.println("Background task started...");
                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();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently doing the following to compensate for boolean's not mapping well to radio
I have an online text editor, very well made however it does not currently
I'm currently using an application in python which works quite well but when I'm
Well not just IE, any browser that doesn't currently support it I want to
I'm currently building a site, which looks very well in Safari, but many elements
Well I'm currently calling a method that requires one char input method, but I
I currently have a Google Map Activity which is apparently working well but doesn't
I am currently studying the beautiful topic of recursive backtracking. I've already tried classical
I currently use masonry plugin in my facebook app. Everything is work well but
I have an application that currently does not support Nexus 7 very well. So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.