Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void processFiles(ActionEvent actionEvent) {
- if (outputDirectory != null) {
- ForkJoinPool pool = new ForkJoinPool(threadsNum.getValue());
- pool.submit(() -> backgroundJob(parallel.isSelected()));
- }
- }
- private void backgroundJob(boolean parallel) {
- double start = System.currentTimeMillis();
- Stream<ImageProcessingJob> stream;
- if (parallel) {
- stream = filesView.getItems().parallelStream();
- } else {
- stream = filesView.getItems().stream();
- }
- stream.forEach(temp -> {
- if (!"zakończone".equals(temp.getStatus())) {
- convertToGrayscale(temp.getFile(), outputDirectory, temp);
- }
- });
- Platform.runLater(() -> time.setText(String.valueOf((System.currentTimeMillis() - start) / 1000)));
- Platform.runLater(() -> time.setVisible(true));
- Platform.runLater(() -> timetext.setVisible(true));
- Platform.runLater(() -> timeunit.setVisible(true));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement