title: Ho to create JavaRx observable which emits synchronous (or blocking) list to all of the subscribers?
body: <p>I'm very new to RxJava, android and Java at all... I am trying to create an observable which emits a synchronized List. Where I am wrong?</p>
  
  <pre><code>public class CurrentLocationHolder {
  
      private List&lt;LocationPoint&gt; locationBuffer = Collections.synchronizedList(new ArrayList&lt;&gt;());
  
      public final PublishSubject&lt;List&lt;LocationPoint&gt;&gt; locationBufferChanged = PublishSubject.create();
  
      public Observable&lt;List&lt;LocationPoint&gt;&gt; observeLocationBufferChanged(boolean emitCurrentValue) {
          return emitCurrentValue ? locationBufferChanged.startWith(locationPointsBuffer) : locationBufferChanged;
      }
  
      public void setLocation(LocationPoint point) {
  
          locationBuffer.add(point);
  
          if (locationBuffer.size() &gt;= 10) {
              locationBufferChanged.onNext(this.locationBuffer);
          }
  
          locationBufferChanged.onCompleted();
  
          locationBuffer.clear();
      }
  }
  </code></pre>
  
  <p>And here is my subscriber #1 object:</p>
  
  <pre><code>public class DatabaseManager {
      private Subscription locationBufferSubscription;
      private static DatabaseManager instance;
  
      public static void InitInstance() {
          if (instance == null) {
              instance = new DatabaseManager();
  
          instance.changeLocationBufferSubscription = 
              CurrentLocationHolder.getInstance().observeLocationBufferChanged()
                  .subscribe(locArray -&gt; {
                      ActiveAndroid.beginTransaction();
                      try {
                          for (int i = 0; i &lt; locArray.size(); i++) {
                              locArray.get(i).save();
                          }
                          ActiveAndroid.setTransactionSuccessful();
                      } finally {
                          ActiveAndroid.endTransaction();
                      }
              });
          }
      }
  }
  </code></pre>
  
  <p>So, if I would create an another subscriber, forexample HttpManager, which will listen to buffer changes too, will my buffer be synchronous for all of the listeners? And will my List be cleared after all of the listeners process all 10 of LocationPoints?
  And isn't my code an overkill?</p>