【发布时间】:2013-09-29 17:55:17
【问题描述】:
这段代码是线程安全的吗?
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
...
});
我很好奇,因为 ArrayList 不是线程安全的数据结构。
【问题讨论】:
-
Rx 设计指南很有帮助:go.microsoft.com/fwlink/?LinkID=205219.
标签: java multithreading thread-safety rx-java