我曾嘗試這樣的代碼:Java的8 parallelStream(...) - >填寫ArrayList的
final List<ScheduleContainer> scheduleContainers = new ArrayList<>();
scheduleResponseContent.getSchedules().parallelStream().forEach(s -> scheduleContainers.addAll(s));
隨着parallelStream我得到一個任意或ArrayIndexOutOfBoundException一個NullPointerException因爲scheduleContainers某些條目爲空。
With ... .stream()...一切正常。 現在我的問題是,如果有可能解決這個問題,或者我誤用了parallelStream?
你如何使用parallenStream加入列表?你可以請秀嗎? –