title: When to use `unSubscribeOn` in rxjava
body: <p>I have been using RxJava for a while. I make use of the <code>subscribeOn</code> and <code>observeOn</code> operators to manage threads. I use <code>subscribeOn</code> to start observable emission in an <code>io</code> or <code>computation</code> thread, and I observe the result in main thread using <code>observeOn(AndroidSchedluers.mainThread())</code></p>
  
  <p>Throughout my app, a stream usually looks like this </p>
  
  <pre><code>compositeDisposable.add(observable()
              .flatMap(result-&gt; { // do something })
              .map(result -&gt; // doSomething)
              .subscribeOn(Schedulers.io())
              .observeOn(AndroidSchedulers.mainThread()))
              .subscribeWith(new DisposableObserver&lt;Object&gt;() {
                              @Override
                              public void onNext(Object o) {
  
                              }
  
                              @Override
                              public void onError(Throwable e) {
  
                              }
  
                              @Override
                              public void onComplete() {
  
                              }
                          }));
  </code></pre>
  
  <p>As you can see, the Observer I'm adding to a <code>CompositeDisposable</code> so that, in case my activity or fragment goes out of scope during the observable doing something in the background thread, I can safely disconnect the observer from the chain to avoid any memory leaks. Pretty straightforward.</p>
  
  <p>But in some of the examples, I have seen the <code>unSubscribeOn</code> operator used to make the unsubscription to be in a specific thread. I am kind of not understanding the actual need for that. Infact I have never used that, I have not been ended up any memory leaks either by not using it. </p>
  
  <p>Is it something we need to use always? Or can anyone explain some use cases where we need to go for <code>unSubscribeOn</code>? </p>
  
  <p>I have referred the official documentation and some of the examples as well, but kind of not digesting it. If someone could explain with a sample, it would be very helpful.</p>