-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Java 9 Concurrency Cookbook, Second Edition
By :

Another typical operation you will want to do with a Stream
is sorting its elements. For example, you may want to sort the elements of the Stream
by name, postal code, or any other numeric value.
With streams, we have other considerations with the so-called encounter order. Some streams may have a defined encounter order (it depends on the source of the Stream
). Some operations work with the elements of the stream in its encountered ordered, such as limit()
, skip()
, and others. This makes that parallel computation for this methods doesn't give us good performance. In these cases, you can speed-up the execution of these methods by deleting the ordering constraint.
In this recipe, you will learn how to sort the elements of Stream
and how to delete the ordering constraint in situations where we don't need the encounter order of Stream
.
The example of this recipe has been implemented using the Eclipse IDE. If you use Eclipse or other IDE such as NetBeans...