title: Realm "Cannot create asynchronous query" while using multiple addChangeListeners
body: <p>I'm getting this type of error:</p>
  
  <pre><code>Fatal Exception: java.lang.IllegalStateException: Cannot create asynchronous query while in a write transaction in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 252
         at io.realm.internal.OsResults.nativeStartListening(OsResults.java)
         at io.realm.internal.OsResults.addListener(OsResults.java:405)
         at io.realm.internal.OsResults.addListener(OsResults.java:412)
         at io.realm.RealmResults.addChangeListener(RealmResults.java:173)
         at io.realm.internal.ObservableCollection$RealmChangeListenerWrapper.onChange(ObservableCollection.java:39)
         at io.realm.internal.ObservableCollection$CollectionObserverPair.onChange(ObservableCollection.java:20)
         at io.realm.internal.ObservableCollection$Callback.onCalled(ObservableCollection.java:64)
         at io.realm.internal.ObservableCollection$Callback.onCalled(ObservableCollection.java:54)
         at io.realm.internal.ObserverPairList.foreach(ObserverPairList.java:109)
         at io.realm.internal.OsResults.notifyChangeListeners(OsResults.java:451)
         at io.realm.internal.OsSharedRealm.nativeBeginTransaction(OsSharedRealm.java)
         at io.realm.internal.OsSharedRealm.beginTransaction(OsSharedRealm.java:269)
         at io.realm.BaseRealm.beginTransaction(BaseRealm.java:401)
         at io.realm.Realm.beginTransaction(Realm.java:146)
  </code></pre>
  
  <p>How can I make sure that I'm not in transaction while I am adding addChangeListeners? A simple approach of <code>mRealm.isInTransaction</code> could help or the problem is in codes structure?</p>
  
  <pre><code>public void update() {
      sData = dataQuery.sort(Data.ORDER, Sort.ASCENDING).findAllAsync();
      sData.addChangeListener(new RealmChangeListener&lt;RealmResults&lt;Data&gt;&gt;() {
          @Override
          public void onChange(RealmResults&lt;Data&gt; element) {
              sDiffData = mRealm.where(DiffData.class)
                      .greaterThanOrEqualTo(...)
                      .lessThan(...)
                      .equalTo(..)
                      .findAllAsync();
              sDiffData.addChangeListener(new RealmChangeListener&lt;RealmResults&lt;...&gt;&gt;() {
                  @Override
                  public void onChange(RealmResults&lt;...&gt; element) {
                      ...
              });
          }
      });
  }
  </code></pre>
  
  <p>I cannot re-produce error myself, but I can see it in crashlytics showing up pretty often.</p>