1. 使用并行流过滤数据
统计1~1000000内所有质数的数量.
1 | public static boolean isPrime(int number){ |
1 | // 串行做法 |
2. 从集合得到并行流
统计集合内所有学生的平均分
1 | List<Student> students = new ArrayList<>(); |
3. 并行排序
对数组进行并行排序.
1 | Arrays.parallelSort(arr); |
数组中的数据赋值
1 | int [] arr = new int[1000000]; |
4. 参考文献
<< Java高并发程序设计 >>(葛一鸣 郭超)