Java Reference
In-Depth Information
Figure C.1. The StreamForker in action
Here the user defines three operations to be performed on a stream indexed by three keys. The
StreamForker then traverses the original stream and forks it into three other streams. At this
point the three operations can be applied in parallel on the forked streams, and the results of
these function applications, indexed with their corresponding keys, are used to populate the
resulting Map.
The execution of all the operations added through the fork method is triggered by the invocation
of the method getResults, which returns an implementation of the Results interface defined as
follows:
public static interface Results {
public <R> R get(Object key);
}
This interface has only one method to which you can pass one of the key Objects used in one of
the fork methods, and that method returns the result of the operation corresponding to that key.
 
Search WWH ::




Custom Search