2016-12-17 10:51:25 -08:00
|
|
|
// concurrent/OnePizza.java
|
2021-01-31 15:42:31 -07:00
|
|
|
// (c)2021 MindView LLC: see Copyright.txt
|
2016-12-17 10:51:25 -08:00
|
|
|
// We make no guarantees that this code is fit for any purpose.
|
|
|
|
// Visit http://OnJava8.com for more book information.
|
|
|
|
import onjava.Timer;
|
|
|
|
|
|
|
|
public class OnePizza {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
Pizza za = new Pizza(0);
|
|
|
|
System.out.println(
|
|
|
|
Timer.duration(() -> {
|
|
|
|
while(!za.complete())
|
|
|
|
za.next();
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Output:
|
|
|
|
Pizza 0: ROLLED
|
|
|
|
Pizza 0: SAUCED
|
|
|
|
Pizza 0: CHEESED
|
|
|
|
Pizza 0: TOPPED
|
|
|
|
Pizza 0: BAKED
|
|
|
|
Pizza 0: SLICED
|
|
|
|
Pizza 0: BOXED
|
2021-01-31 15:42:31 -07:00
|
|
|
1665
|
2016-12-17 10:51:25 -08:00
|
|
|
*/
|