forked from java8/Java8InAction
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsyncShopClient.java
More file actions
21 lines (18 loc) · 782 Bytes
/
AsyncShopClient.java
File metadata and controls
21 lines (18 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package lambdasinaction.chap11;
import java.util.concurrent.Future;
public class AsyncShopClient {
public static void main(String[] args) {
AsyncShop shop = new AsyncShop("BestShop");
long start = System.nanoTime();
Future<Double> futurePrice = shop.getPrice("myPhone");
long incocationTime = ((System.nanoTime() - start) / 1_000_000);
System.out.println("Invocation returned after " + incocationTime + " msecs");
try {
System.out.println("Price is " + futurePrice.get());
} catch (Exception e) {
throw new RuntimeException(e);
}
long retrivalTime = ((System.nanoTime() - start) / 1_000_000);
System.out.println("Price returned after " + retrivalTime + " msecs");
}
}