title: RxJava Android AmbWith Operator causes NetworkOnMainThread Exception
body: <p>I am experimenting with RxJava on Android at the moment and encountered a problem trying to use the AmbWith Operator with two Observables.</p>
  
  <p>As I understood in the definition of amb here 
  <a href="http://reactivex.io/documentation/operators/amb.html" rel="nofollow">http://reactivex.io/documentation/operators/amb.html</a></p>
  
  <p>only the first Observable to send a notification is taken, the rest ignored and discarded. </p>
  
  <p>I connected two Observables, one does a network call(with retrofit) 
  the other one responds with data from the memory. </p>
  
  <p>The code for this looks like this:</p>
  
  <pre><code>    retrofitService.loadInfo()
              .subscribeOn(Schedulers.newThread())
              .observeOn(AndroidSchedulers.mainThread())
              //the observable here returns an item from in memory and should be observed on the ui thread
              .ambWith(observable.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()))
              .subscribe(action);
  </code></pre>
  
  <p>The problem now is, if the second observable emits an item first(which is very likely) the first observable gets cancelled. This results in an NetworkOnMainThread if the webservice was already started.</p>
  
  <p>It works fine if I remove the </p>
  
  <pre><code>    .observeOn(AndroidSchedulers.mainThread()
  </code></pre>
  
  <p>for the second Observable, but I need the result in the ui.</p>
  
  <p>My guess is, that the amb operator is executed on the main thread and somehow the cancel operation ends up in the main thread.</p>
  
  <p>Did I miss something there?
  Does anybody know how to get around this?</p>
  
  <p>Any help is appreciated.</p>