原文链接
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors;
public class ExecutorsDemo {
public static void main(String[] args) { ExecutorService executorService = Executors.newSingleThreadExecutor(); executorService.submit(() -> { try { Thread.currentThread().wait(); } catch (InterruptedException e) { e.printStackTrace(); } });
} }
|
猜测在同一个thread group的thread会互相block住
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public class PlayWithDefaultThreadFactory { public static void main(String[] args) { DefaultThreadFactory factory = new DefaultThreadFactory();
Thread t = factory.newThread(() -> { try { sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } });
t.start();
t.interrupt(); } }
|