(String[] args)
| 14 | |
| 15 | public class WorkStealingPool { |
| 16 | public static void main(String[] args) |
| 17 | throws InterruptedException { |
| 18 | System.out.println( |
| 19 | Runtime.getRuntime().availableProcessors()); |
| 20 | ExecutorService exec = |
| 21 | Executors.newWorkStealingPool(); |
| 22 | IntStream.range(0, 10) |
| 23 | .mapToObj(n -> new ShowThread()) |
| 24 | .forEach(exec::execute); |
| 25 | exec.awaitTermination(1, TimeUnit.SECONDS); |
| 26 | } |
| 27 | } |
| 28 | /* Output: |
| 29 | 8 |