@Test public void disposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { final CompositeDisposable cd = new CompositeDisposable(); Runnable run = new Runnable() { @Override public void run() { cd.dispose(); } }; TestHelper.race(run, run); } }
@Override public void dispose() { if (disposed) { return; } OpenHashSet<Disposable> set; synchronized (this) { if (disposed) { return; } disposed = true; set = resources; resources = null; } dispose(set); }
CompositeDisposable implements Disposable, DisposableContainer { @Override public void dispose() { if (disposed) { return; } OpenHashSet<Disposable> set; synchronized (this) { if (disposed) { return; } disposed = true; set = resources; resources = null; } dispose(set); } }
CompositeDisposable implements Disposable, DisposableContainer { @Override public void dispose() { if (disposed) { return; } OpenHashSet<Disposable> set; synchronized (this) { if (disposed) { return; } disposed = true; set = resources; resources = null; } dispose(set); } CompositeDisposable();  CompositeDisposable(@NonNull Disposable... resources);  CompositeDisposable(@NonNull Iterable<? extends Disposable> resources); }
CompositeDisposable implements Disposable, DisposableContainer { @Override public void dispose() { if (disposed) { return; } OpenHashSet<Disposable> set; synchronized (this) { if (disposed) { return; } disposed = true; set = resources; resources = null; } dispose(set); } 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(); }
CompositeDisposable implements Disposable, DisposableContainer { @Override public void dispose() { if (disposed) { return; } OpenHashSet<Disposable> set; synchronized (this) { if (disposed) { return; } disposed = true; set = resources; resources = null; } dispose(set); } 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();  }