title: RxJava - How to set Observer to block
body: <p>I would like my <code>Observable</code> to block until the operation is complete and then continue with the next method calls etc.  Take a look at this code:</p>
  
  <pre class="lang-java prettyprint-override"><code>import rx.Observable;
  import rx.android.schedulers.AndroidSchedulers;
  import rx.functions.Action1;
  import rx.functions.Func1;
  
  Observable observer1 = Observable.just(1, 2, 3)
          .observeOn(AndroidSchedulers.mainThread());
  
  Observable observer2 = observer1.map(new Func1&lt;Integer, Integer&gt;() {
      @Override
      public Integer call(Integer myint) {
          //multiples each int by 2
          return myint * 2;
      }
  });
  
  observer2.observeOn(AndroidSchedulers.mainThread())
          .subscribeOn(AndroidSchedulers.mainThread());
  
  observer2.subscribe(new Action1&lt;Integer&gt;() {
      @Override
      public void call(Integer i) {
          System.out.println("this is the Integer multiplied by two:" + i);
      }
  });
  
  System.out.println("I want this statement to come after multiplication completes");
  </code></pre>
  
  <p>I realize I can use the <code>onComplete</code> call back but that's not my point.  I am trying to figure out how I can block an observer until it completes and then continue with the rest of my code. At this moment the log looks like this:</p>
  
  <blockquote>
    <p>I/System.out﹕ I want this statement to come after multiplication completes<br>
       I/System.out﹕ this is the Integer multiplied by two:2<br>
       I/System.out﹕ this is the Integer multiplied by two:4<br>
       I/System.out﹕ this is the Integer multiplied by two:6  </p>
  </blockquote>
  
  <p>Also notice how I am observing and subscribing all on the MainThread, is this done by default if I don't specify?</p>