(String[] args)
| 9 | public class PizzaStreams { |
| 10 | static final int QUANTITY = 5; |
| 11 | public static void main(String[] args) { |
| 12 | Timer timer = new Timer(); |
| 13 | IntStream.range(0, QUANTITY) |
| 14 | .mapToObj(Pizza::new) |
| 15 | .parallel() // [1] |
| 16 | .forEach(za -> { |
| 17 | while(!za.complete()) |
| 18 | za.next(); |
| 19 | }); |
| 20 | System.out.println(timer.duration()); |
| 21 | } |
| 22 | } |
| 23 | /* Output: |
| 24 | Pizza 0: ROLLED |