Advertisement
Pagoniusz

Untitled

Apr 23rd, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1.   public void processFiles(ActionEvent actionEvent) {
  2.         if (outputDirectory != null) {
  3.             ForkJoinPool pool = new ForkJoinPool(threadsNum.getValue());
  4.             pool.submit(() -> backgroundJob(parallel.isSelected()));
  5.         }
  6.     }
  7.  
  8.     private void backgroundJob(boolean parallel) {
  9.         double start = System.currentTimeMillis();
  10.         Stream<ImageProcessingJob> stream;
  11.  
  12.         if (parallel) {
  13.             stream = filesView.getItems().parallelStream();
  14.         } else {
  15.             stream = filesView.getItems().stream();
  16.         }
  17.  
  18.         stream.forEach(temp -> {
  19.             if (!"zakończone".equals(temp.getStatus())) {
  20.                 convertToGrayscale(temp.getFile(), outputDirectory, temp);
  21.             }
  22.         });
  23.         Platform.runLater(() -> time.setText(String.valueOf((System.currentTimeMillis() - start) / 1000)));
  24.         Platform.runLater(() -> time.setVisible(true));
  25.         Platform.runLater(() -> timetext.setVisible(true));
  26.         Platform.runLater(() -> timeunit.setVisible(true));
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement