From 5a118455340a85b5d1ad3b846d680b33d896e869 Mon Sep 17 00:00:00 2001 From: kyriewhluo Date: Tue, 6 Aug 2024 10:19:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A4=E6=AC=A1=E6=8F=90=E4=BA=A4=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=B1=95=E7=A4=BA=E4=BA=86=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E7=AE=80=E5=8D=95=E7=9A=84=E5=AD=97=E8=8A=82=E6=B5=81=E5=A4=84?= =?UTF-8?q?=E7=90=86=E7=A4=BA=E4=BE=8B=EF=BC=8C=E4=BB=A5=E5=8F=8A=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E6=8E=89=E7=9A=84=E5=B9=B6=E5=8F=91=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E3=80=82=E4=B8=BB=E8=A6=81=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E6=98=AF=E9=80=9A=E8=BF=87`ByteArrayInputStream`=E4=BB=8E?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=9E=84=E5=BB=BA=E5=AD=97=E8=8A=82?= =?UTF-8?q?=E6=B5=81=EF=BC=8C=E7=84=B6=E5=90=8E=E4=BD=BF=E7=94=A8=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E8=AF=BB=E5=8F=96=E5=AD=97=E8=8A=82=E6=B5=81=E5=B9=B6?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=87=BA=E6=9D=A5=E3=80=82=E8=99=BD=E7=84=B6?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E7=9A=84=E4=BB=A3=E7=A0=81=E4=B8=8D=E5=8C=85?= =?UTF-8?q?=E5=90=AB=E5=AE=9E=E9=99=85=E7=9A=84=E7=BA=BF=E7=A8=8B=E6=B1=A0?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=EF=BC=8C=E4=BD=86=E9=80=9A=E8=BF=87=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E5=8F=AF=E4=BB=A5=E7=9C=8B=E5=87=BA=EF=BC=8C=E5=8E=9F?= =?UTF-8?q?=E5=85=88=E5=8F=AF=E8=83=BD=E5=AD=98=E5=9C=A8=E5=AF=B9=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=B1=A0=E7=9A=84=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82=E6=AD=A4=E4=BB=A3=E7=A0=81=E7=89=87=E6=AE=B5=E4=BD=9C?= =?UTF-8?q?=E4=B8=BA=E4=B8=80=E4=B8=AA=E5=9F=BA=E7=A1=80=EF=BC=8C=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E7=94=A8=E4=BA=8E=E6=B5=8B=E8=AF=95=E6=88=96=E6=BC=94?= =?UTF-8?q?=E7=A4=BAJava=E4=B8=AD=E7=9A=84IO=E5=A4=84=E7=90=86=E5=92=8C?= =?UTF-8?q?=E5=B9=B6=E5=8F=91=E7=BC=96=E7=A8=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/whaifree/test/TestCacheThreadPool.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/main/java/cn/whaifree/test/TestCacheThreadPool.java diff --git a/src/main/java/cn/whaifree/test/TestCacheThreadPool.java b/src/main/java/cn/whaifree/test/TestCacheThreadPool.java new file mode 100644 index 0000000..1ad3399 --- /dev/null +++ b/src/main/java/cn/whaifree/test/TestCacheThreadPool.java @@ -0,0 +1,48 @@ +package cn.whaifree.test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class TestCacheThreadPool { + + public static void main(String[] args) throws IOException { + + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < 20; i++) { + stringBuilder.append(i); + } + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(stringBuilder.toString().getBytes(Charset.defaultCharset())); + + byte[] buffer = new byte[10]; + int length = 0; + + while ((length = byteArrayInputStream.read(buffer)) != -1) { + System.out.println(new String(buffer, 0, length)); + System.out.println("\n"); + } + +// ExecutorService executorService = Executors.newCachedThreadPool(); +// for (int i = 0; i < 10; i++) { +// int finalI = i; +// executorService.submit(new Runnable() { +// @Override +// public void run() { +// try { +// Thread.sleep(1000); +// } catch (InterruptedException e) { +// throw new RuntimeException(e); +// } +// +// System.out.println(finalI +// +" "+Thread.currentThread().getName()); +// } +// }); +// } + } + + +}