(String[] args)
| 7 | |
| 8 | public class CachedThreadPool2 { |
| 9 | public static void main(String[] args) { |
| 10 | ExecutorService exec = |
| 11 | Executors.newCachedThreadPool(); |
| 12 | IntStream.range(0, 10) |
| 13 | .mapToObj(InterferingTask::new) |
| 14 | .forEach(exec::execute); |
| 15 | exec.shutdown(); |
| 16 | } |
| 17 | } |
| 18 | /* Output: |
| 19 | 3 pool-1-thread-4 100 |