Esempio n. 1
0
 @AfterClass
 public static void tearDown() throws InterruptedException, ExecutionException, IOException {
   DirDataImpl dirData = new DirDataImpl();
   DirDataImpl.setNumber(3334);
   List<String> paths = dirData.dividePath(rootPath, 30, THREADS);
   List<Future<String>> list = new ArrayList<>();
   try {
     for (String p : paths) {
       Future<String> submit =
           executor.submit(
               () -> {
                 dirData.delDir(p, 6);
                 return "It done!";
               });
       list.add(submit);
     }
     for (Future<String> future : list) {
       future.get();
     }
   } finally {
     executor.shutdown();
     while (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
       LOG.info("Awaiting completion of threads.");
     }
   }
   FileUtils.deleteDirectory(new File(rootPath));
 }
Esempio n. 2
0
 @BeforeClass
 public static void setUp() throws InterruptedException, ExecutionException {
   DirDataImpl dirData = new DirDataImpl();
   DirDataImpl.setNumber(3334);
   String path = dirData.buildPath(rootPath, 30);
   dirData.createDir(path);
   List<String> paths = dirData.dividePath(rootPath, 30, THREADS);
   List<Future<String>> list = new ArrayList<>();
   for (String p : paths) {
     Future<String> submit =
         executor.submit(
             () -> {
               dirData.createFiles(p, 6);
               return "It done!";
             });
     list.add(submit);
   }
   for (Future<String> future : list) {
     future.get();
   }
 }