Using the CompletableFuture object, we can separate sending the request for data to the measuring system (and creating the CompletableFuture object) from getting the result from the CompletableFuture object. This is exactly the scenario we described when explaining what asynchronous processing is. Let's demonstrate it in the code. Similar to the way we submitted the requests to a measuring system, we can do it using the CompletableFuture.supplyAsync() static method:
List<CompletableFuture<Double>> list = ids.stream() .map(id -> CompletableFuture.supplyAsync(() -> mSys.apply(id))) .collect(Collectors.toList());
The difference is that the supplyAsync() method does not wait for the call to the measuring system ...