0

I am learning RxJava.

This is code

public void d(){
        long startTime = System.currentTimeMillis();
        Observable.range(1, 1000000).map(c -> c*c).subscribe();
        long endTime = System.currentTimeMillis();
        System.out.println(endTime - startTime);
    }

This code just calculates the square of no. Is it doing it in parallel?

I mean is it sequentially iterating 1 , 2 ,3 etc and calculating square or is it using Parallel processing?

Ankit Bansal
  • 2,162
  • 8
  • 42
  • 79
  • 1
    Observables are sequential by nature, going parallel requires splitting the flow. Looks like you should read some tutorials about RxJava first. – akarnokd Oct 25 '17 at 09:32
  • Can you provide the links to some good tutorial code wise – Ankit Bansal Oct 25 '17 at 09:34
  • https://stackoverflow.com/questions/35425832/rxjava-and-parallel-execution-of-observer-code – akarnokd Oct 25 '17 at 09:34
  • Single Observable in sequential. Is it possible I create three different Observables and execute them in parallel and when all executes , I zip there result? – Ankit Bansal Oct 25 '17 at 09:39

1 Answers1

1

My advice would be to always read the documentation from the official docs before posting any question.

I would suggest that you start with RxJava-Operators page, as it contains tree to choose which operators suits your purpose.

Now, coming back to your question, to understand concurrency and parallelization, please check RxJava-Schedulers page.

hemal7735
  • 321
  • 1
  • 3
  • 18