title: Background service and service monitoring in javafx
body: <p>I am developing a javafx project for uploading image file to a aws s3 bucket. Before uploading the images I check the validity of images like height, weight and size of the images. As the uploading process is time consuming, I create a monitor to monitor (screen) the uploading progress. </p>
  
  <pre><code>class Monitor extends Stage {
  private TextArea textArea = new TextArea();
      Monitor(){
          this.setTitle("Image Uploading Monitor");
          this.getIcons().add(new Image("/rok.png"));
          this.setFullScreen(false);
          this.setResizable(false);
          this.textArea.setEditable(false);
          this.textArea.setPrefSize(700, 450);
          Pane pane = new Pane();
          pane.getChildren().add(this.textArea);
          Scene scene = new Scene(pane, 700, 450);
          this.setScene(scene);
      }
  
      void print(String string) {
          this.textArea.appendText(string);
          this.textArea.selectPositionCaret(textArea.getLength());
      }
  }
  </code></pre>
  
  <p>Then after every image uploading I want to print a message in the monitor</p>
  
  <pre><code>for (File image : images) {
     uploadFileToS3Bucket(image, "uploadingLocation");
     monitor.print("Uploading image"+image.getName()+"\n");
  }
  </code></pre>
  
  <p>The code is working fine, but the problem is, the monitor show the output after  all images uploading. </p>
  
  <p>Because I run hole project in a single thread. How can I use multi thread to solve the problem? </p>