title: Keep main thread wait until RxJava Observable complete
body: <p>I want to hold my main thread until RxJava 2 Observable complete. My coding is as here. The case is when I request the method contains below code, method was just executing without waiting for observable     </p>
  
  <pre><code> Observable
                          .fromArray(observableList)
                          .subscribeOn(Schedulers.io())
                          .subscribe(new Consumer&lt;List&lt;Observable&lt;List&lt;String&gt;&gt;&gt;&gt;() {
                          @Override
                          public void accept(List&lt;Observable&lt;List&lt;String&gt;&gt;&gt; list) throws Exception {
  
                              for (Observable&lt;List&lt;String&gt;&gt; observable : list) {
                                  System.out.println("Thread name " + Thread.currentThread().getName());
  
                                  observable.subscribe(new Consumer&lt;List&lt;String&gt;&gt;() {
                                      @Override
                                      public void accept(List&lt;String&gt; t) throws Exception {
  
                                          Gson jsonBuilder = new Gson();
  
                                          Object obj = new Object();
  
                                          JsonElement element = jsonBuilder.toJsonTree(obj);
  
                                          element.getAsJsonObject().addProperty(t.get(0), t.get(1));
  
                                          Gson g = new Gson();
                                          Object out = g.fromJson(t.get(1), Object.class);
  
                                          microResponses.put(t.get(0), out);
                                      }
                                  });
  
                              }
  
                          }
  
  
           });
  </code></pre>