title: How to wait until JavaRx2 Flowable will finish all its tasks?
body: <p>I am trying to learn the basics of RxJava2 library and right now I am stuck at the following moment:<br>
  I have generated <code>myFlowable</code> via <code>Flowable.generate(...)</code> and now I need to wait while all the tasks will finish its execution, before I can proceed further.<br>
  This is the code to showcase the problem:  </p>
  
  <pre><code>myFlowable.parallel()
              .runOn(Schedulers.computation())
              .map(val -&gt; myCollection.add(val))
              .sequential()
              .subscribe(val -&gt; {
                  System.out.println("Thread from subscribe: " + Thread.currentThread().getName());
                  System.out.println("Value from subscribe: " + val.toString());
              });
      System.out.println("Before sleep - Number of objects: " + myCollection.size());
      try {
          Thread.sleep(1000);
          System.out.println("After sleep - Number of objects: " + myCollection.size());
      } catch (InterruptedException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>I run through all my tasks and add the results to collection. And if I check the collection size right after myFlowable block then it will be different, if I check it after small <code>Thread.sleep()</code>. Is there any way to check that all the tasks finished its execution and we can proceed further? Any help or guidance will be greatly appreciated.</p>