我需要在上面提到的线程中使用parallelStream()。需要调用使用线程局部变量的myService。在java8中使用parallelstream()时,是否有任何机制来设置ThreadLocal。List<MyObject> result = myList.parallelStream().map(myObject -> {
//call myService with the Threadlocal
<ScheduleContainer> scheduleContainers = new ArrayList<>();使用scheduleContainers,我可以得到一个ArrayIndexOutOfBoundException或一个NullpointerException,因为在parallelStream我现在的问题是,是否有可能修复这个问题,还是我误用了<