From 0fe3c5c02fce2b3b885cb12cc8a06090d05c74b7 Mon Sep 17 00:00:00 2001 From: erdanergou Date: Mon, 31 Oct 2022 11:45:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9D=A1=E5=BD=A2=E7=A0=81?= =?UTF-8?q?=E4=B8=8E=E7=89=A9=E6=96=99=E7=BC=96=E7=A0=81=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/AsyncThreadUtil.java | 38 +++ target/classes/.restartTriggerFile | 0 .../materialBarCode/materialBarCode_out.html | 282 ++++++++++++++++++ 3 files changed, 320 insertions(+) create mode 100644 src/main/java/com/dreamchaser/depository_manage/utils/AsyncThreadUtil.java create mode 100644 target/classes/.restartTriggerFile create mode 100644 target/classes/templates/pages/materialBarCode/materialBarCode_out.html diff --git a/src/main/java/com/dreamchaser/depository_manage/utils/AsyncThreadUtil.java b/src/main/java/com/dreamchaser/depository_manage/utils/AsyncThreadUtil.java new file mode 100644 index 00000000..c96003c4 --- /dev/null +++ b/src/main/java/com/dreamchaser/depository_manage/utils/AsyncThreadUtil.java @@ -0,0 +1,38 @@ +package com.dreamchaser.depository_manage.utils; + +import java.util.Random; +import java.util.concurrent.*; + +public class AsyncThreadUtil { + + private ExecutorService executorService = Executors.newCachedThreadPool(); + + /** + * * 使用completionService收集callable结果 + * * @throws ExecutionException + * * @throws InterruptedException + * + */ + public void completionServiceCount() throws InterruptedException, ExecutionException { + // 定义线程池 + + CompletionService completionService = new ExecutorCompletionService( + executorService); + int threadNum = 5; + executorService.shutdown(); + } + + public Callable getTask(final int no) { + final Random rand = new Random(); + Callable task = new Callable() { + @Override + public Integer call() throws Exception { + int time = rand.nextInt(100) * 100; + System.out.println("thead:" + no + " time is:" + time); + Thread.sleep(time); + return no; + } + }; + return task; + } +} diff --git a/target/classes/.restartTriggerFile b/target/classes/.restartTriggerFile new file mode 100644 index 00000000..e69de29b diff --git a/target/classes/templates/pages/materialBarCode/materialBarCode_out.html b/target/classes/templates/pages/materialBarCode/materialBarCode_out.html new file mode 100644 index 00000000..813873d0 --- /dev/null +++ b/target/classes/templates/pages/materialBarCode/materialBarCode_out.html @@ -0,0 +1,282 @@ + + + + + layui + + + + + + + +
+
+ + + + + + +
+ + +
+
+ + + + + \ No newline at end of file