1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package ch.hslu.exercises.sw11.ex4.findfile;
17
18 import java.io.File;
19 import java.time.Duration;
20 import java.util.concurrent.ExecutionException;
21 import java.util.concurrent.ExecutorService;
22 import java.util.concurrent.Executors;
23 import java.util.concurrent.Future;
24
25 import org.slf4j.LoggerFactory;
26 import org.slf4j.Logger;
27
28
29
30
31 public final class DemoFindFile {
32
33 private static final Logger LOG = LoggerFactory.getLogger(DemoFindFile.class);
34
35
36
37
38 private DemoFindFile() {
39 }
40
41
42
43
44
45
46 public static void main(final String[] args) throws ExecutionException, InterruptedException {
47 long start;
48 long stop;
49 Duration duration;
50 final String search = "CNA-Labor1_-_Firewall_Basics.pdf";
51 final File rootDir = new File(System.getProperty("user.home"));
52 LOG.info("Start searching '{}' recurive in '{}'", search, rootDir);
53 start = System.currentTimeMillis();
54
55 stop = System.currentTimeMillis();
56 duration = Duration.ofMillis(stop - start);
57 LOG.info("Found in {} msec.", duration.toMillis());
58 LOG.info("Find '{}' concurrent in '{}'", search, rootDir);
59 final FindFileTask root = new FindFileTask(search, rootDir);
60 start = System.currentTimeMillis();
61 LOG.info(root.invoke());
62 stop = System.currentTimeMillis();
63 duration = Duration.ofMillis(stop - start);
64 LOG.info("Found in {} msec.", duration.toMillis());
65 final ExecutorService executor = Executors.newSingleThreadExecutor();
66 final MaximumNew max = new MaximumNew();
67 Future<Integer> submit = executor.submit(max);
68 int maxV = submit.get();
69 }
70 }