Skip to content

Commit a636b87

Browse files
authored
2.x: update readme parallel example (#5062)
1 parent 471d590 commit a636b87

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ Flowable.range(1, 10)
135135

136136
Practically, paralellism in RxJava means running independent flows and merging their results back into a single flow. The operator `flatMap` does this by first mapping each number from 1 to 10 into its own individual `Flowable`, runs them and merges the computed squares.
137137

138+
Starting from 2.0.5, there is an *experimental* operator `parallel()` and type `ParallelFlowable` that helps achieve the same parallel processing pattern:
139+
140+
```java
141+
Flowable.range(1, 10)
142+
.parallel()
143+
.runOn(Schedulers.computation())
144+
.map(v -> v * v)
145+
.sequential()
146+
.blockingSubscribe(System.out::println);
147+
```
148+
138149
`flatMap` is a powerful operator and helps in a lot of situations. For example, given a service that returns a `Flowable`, we'd like to call another service with values emitted by the first service:
139150
140151
```java

0 commit comments

Comments
 (0)