Sorting a List in parallel without creating a temporary array in Java 8

后端 未结 5 827
小鲜肉
小鲜肉 2020-12-03 13:13

Java 8 provides java.util.Arrays.parallelSort, which sorts arrays in parallel using the fork-join framework. But there\'s no corresponding Collections.parallelSort

5条回答
  •  感动是毒
    2020-12-03 13:54

    Use the following:

    yourCollection.parallelStream().sorted().collect(Collectors.toList());
    

    This will be parallel when sorting, because of parallelStream(). I believe this is what you mean by parallel sort?

提交回复
热议问题