public static void testProductStream(List<Product> list) { long start = System.currentTimeMillis(); Optional optional = list.stream().max((p1, p2)-> p1.hot - p2.hot); System.out.println(optional.get()); long end = System.currentTimeMillis(); System.out.println("testProductStream:" + (end - start) + "ms"); } public static void testProductParallelStream(List<Product> list) { long start = System.currentTimeMillis(); Optional optional = list.stream().max((p1, p2)-> p1.hot - p2.hot); System.out.println(optional.get()); long end = System.currentTimeMillis(); System.out.println("testProductParallelStream:" + (end - start) + "ms"); }
估计是直接粘下来 没注意 你手动改一下就可以了
Optional optional = list.parallelStream().max((p1, p2)-> p1.hot - p2.hot);