Selaa lähdekoodia

加入线程处理

wangliang 1 viikko sitten
vanhempi
commit
37afa8acd0
1 muutettua tiedostoa jossa 9 lisäystä ja 2 poistoa
  1. 9 2
      src/main/java/com/qmth/cet/plug/api/CetPlugController.java

+ 9 - 2
src/main/java/com/qmth/cet/plug/api/CetPlugController.java

@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.io.IOException;
 import java.util.Objects;
+import java.util.StringJoiner;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
@@ -59,19 +60,25 @@ public class CetPlugController {
     @Aac(auth = false)
     public Result test() throws IOException, InterruptedException {
         log.info("test is come in");
+        long start = System.currentTimeMillis();
+        StringJoiner stringJoiner = new StringJoiner("");
         String projectPath = System.getProperty("user.dir");
         int cpuNum = Runtime.getRuntime().availableProcessors();
         ExecutorService executor = Executors.newFixedThreadPool(Math.abs(cpuNum / 2));
         if (Objects.nonNull(cet4Dir)) {
             logicService.execFile(cet4Dir, projectPath, "cet4", executor);
         }
+        if (Objects.nonNull(cet6Dir)) {
+            logicService.execFile(cet6Dir, projectPath, "cet6", executor);
+        }
         executor.shutdown();
         while (!executor.awaitTermination(1, TimeUnit.MINUTES)) {
             log.info("线程池没有关闭");
         }
         log.info("线程池已经关闭");
+        long end = System.currentTimeMillis();
+        stringJoiner.add("============耗时============:").add((end - start) / 1000 + "").add("秒");
+        log.info("request:{}", stringJoiner.toString());
         return ResultUtil.ok();
     }
-
-
 }