java8并行流计算

1. 自定义forkJoin池

try {
                Long start88 = System.currentTimeMillis();
                ForkJoinPool forkJoinPool = new ForkJoinPool(1000);
                forkJoinPool.submit(()->{
                    channelResultSeries.parallelStream().forEach(series -> {
                        String channelid = series.getTags().get("channelid");
                        List> channelValues = series.getValues();
                        List> videoValues = queryResultMap.get(channelid);
                        Map stringMap = getChannelInfoByChannelId(channelid,channelValues,videoValues, startTime, endTime);
                        resultLists.add(stringMap);
                    });
                }).get();
                logger.info("ForkJoinPool spend time is :"+(System.currentTimeMillis()-start88));
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }

 

你可能感兴趣的:(java1.8特性)