From 77d15af23fad5bce32c3672183f9e681c14fe406 Mon Sep 17 00:00:00 2001 From: pythonCat Date: Mon, 13 Aug 2018 17:03:54 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=8A=E5=9B=BE=E8=A7=A3Java=E5=A4=9A?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E8=AE=BE=E8=AE=A1=E6=A8=A1=E5=BC=8F=E3=80=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 代码路径在此 --- src/com/pycat/multi/Main.java | 28 +++++++++++++++++++++++++++ src/com/pycat/multi/package-info.java | 5 +++++ 2 files changed, 33 insertions(+) create mode 100644 src/com/pycat/multi/Main.java create mode 100644 src/com/pycat/multi/package-info.java diff --git a/src/com/pycat/multi/Main.java b/src/com/pycat/multi/Main.java new file mode 100644 index 0000000..0bf4aa0 --- /dev/null +++ b/src/com/pycat/multi/Main.java @@ -0,0 +1,28 @@ +package com.pycat.multi; + +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; + +/** + * Created by cat on 2018/8/13. + * + * @implNote who you are + */ +public class Main { + + public static void main(String[] args) { + ThreadFactory factory = Executors.defaultThreadFactory(); + Thread th = factory.newThread(() -> { + + for (int i = 0; i < 10; i++) { + System.out.print("Nice! "); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + th.start(); + } +} diff --git a/src/com/pycat/multi/package-info.java b/src/com/pycat/multi/package-info.java new file mode 100644 index 0000000..6e6d387 --- /dev/null +++ b/src/com/pycat/multi/package-info.java @@ -0,0 +1,5 @@ +/** + * Created by cat on 2018/8/13. + * code for 《图解Java多线程设计模式》 + */ +package com.pycat.multi; \ No newline at end of file