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<List<Object>> channelValues = series.getValues();
                        List<List<Object>> videoValues = queryResultMap.get(channelid);
                        Map<String, Object> 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();
            }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章