|
1 | | -package com.loon.multithreading; |
2 | | - |
3 | | -import java.util.concurrent.Executor; |
4 | | -import java.util.concurrent.ExecutorService; |
5 | | -import java.util.concurrent.Executors; |
6 | | - |
7 | | -/** |
8 | | - * Created with IntelliJ IDEA. |
9 | | - * User: Loon |
10 | | - * Date: 13-4-7 |
11 | | - * Time: 下午9:12 |
12 | | - * To change this template use File | Settings | File Templates. |
13 | | - */ |
14 | | -public class MainThread { |
15 | | - |
16 | | - public static void main(String[] args) { |
17 | | -// LiftOff lifrOff = new LiftOff(); |
18 | | -// lifrOff.run(); |
19 | | - |
20 | | - // 1.5新特性,启动线程 |
21 | | - // newCachedThreadPool newSingleThreadExecutor newScheduledThreadPool newFixedThreadPool |
22 | | - ExecutorService executorService = Executors.newCachedThreadPool(); |
23 | | - |
24 | | - for (int i=0 ;i<5 ;i++) |
25 | | - executorService.submit(new LiftOff()); |
26 | | - executorService.shutdown(); |
27 | | - } |
28 | | -} |
| 1 | +package com.loon.multithreading; |
| 2 | + |
| 3 | +import java.util.concurrent.Executor; |
| 4 | +import java.util.concurrent.ExecutorService; |
| 5 | +import java.util.concurrent.Executors; |
| 6 | + |
| 7 | +/** |
| 8 | + * Created with IntelliJ IDEA. |
| 9 | + * User: Loon |
| 10 | + * Date: 13-4-7 |
| 11 | + * Time: 下午9:12 |
| 12 | + * To change this template use File | Settings | File Templates. |
| 13 | + */ |
| 14 | +public class MainThread { |
| 15 | + |
| 16 | + public static void main(String[] args) { |
| 17 | +// LiftOff lifrOff = new LiftOff(); |
| 18 | +// lifrOff.run(); |
| 19 | + |
| 20 | + |
| 21 | + // 1.5新特性,启动线程 |
| 22 | + // newCachedThreadPool newSingleThreadExecutor newScheduledThreadPool newFixedThreadPool |
| 23 | + ExecutorService executorService = Executors.newCachedThreadPool(); |
| 24 | + |
| 25 | + for (int i = 0; i < 5; i++) |
| 26 | + executorService.submit(new LiftOff()); |
| 27 | + executorService.shutdown(); |
| 28 | + } |
| 29 | +} |
0 commit comments