I have Observable called messages which contains several messages.I want to process these messages at the same time.How can i do this using rxJava??
messages.(code to execute observable items parallel).subscribe(msg->process(msg))
(If the observable contains five different messages then I need to process these five messages in five seperate threads)
If you want to stay in the Observable world, you can flatMap each element with subscribeOn and computation you want in parallel:
Observable.range(1, 10)
.flatMap(v ->
Observable.fromCallable(() -> compute(v))
.subscribeOn(Schedulers.computation)
)
.subscribe(e -> { }, Throwable::printStackTrace);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With