Is this code thread-safe?
Observable<String> observable = ... // some observable that calls
// onNext from a background thread
observable
.scan(new ArrayList<String>(), (List<String> acc, String next) -> {
acc.add(next);
return acc;
})
.subscribe( list -> {
// do somethind with sequence of lists
...
});
I'm curious because ArrayList is not a thread-safe data structure.