CompositeDisposable implements Disposable, DisposableContainer { @Override public boolean add(@NonNull Disposable d) { ObjectHelper.requireNonNull(d, "d is null"); if (!disposed) { synchronized (this) { if (!disposed) { OpenHashSet<Disposable> set = resources; if (set == null) { set = new OpenHashSet<Disposable>(); resources = set; } set.add(d); return true; } } } d.dispose(); return false; } CompositeDisposable();  CompositeDisposable(@NonNull Disposable... resources);  CompositeDisposable(@NonNull Iterable<? extends Disposable> resources); @Override void dispose(); @Override boolean isDisposed(); @Override boolean add(@NonNull Disposable d); boolean addAll(@NonNull Disposable... ds); @Override boolean remove(@NonNull Disposable d); @Override boolean delete(@NonNull Disposable d); void clear(); int size();  }
@Test public void addRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { final CompositeDisposable cd = new CompositeDisposable(); Runnable run = new Runnable() { @Override public void run() { cd.add(Disposables.empty()); } }; TestHelper.race(run, run); } }