Sorting arrays in parallel is a JDK enhancement, which is part of the Java 9 release, which should yield significant performance improvements.
JDK enhancement proposal 103 brings a new way of array sorting which uses the Fork/Join parallelism technique to provide sorting of arrays in parallel. This new feature has been added in the Java 8 release.
Currently, we have two sorting implementations, one sorts arrays and another sorts collections. These two implementations perform sort in a single thread. The parallel array sorting enhancement will allow us to sort things in parallel which has a significant performance benefit.
I have tested this new feature with the following code:
The output of the aforementioned code snippet:
The performance benefit for the smaller sized array may seem insignificant, however, when the array grows, the outcome becomes quite impactful.
Here is a graph:
The machine I have used for this test:
This new feature is defined for all primitive array types (except boolean), Comparable object types and any arbitrary Object types using a supplied Comparator. For more details, take a look at the proposal at http://openjdk.java.net/jeps/103.
This article was first published at DZone See the original article here.