@Test public void disposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { final ListCompositeDisposable cd = new ListCompositeDisposable(); Runnable run = new Runnable() { @Override public void run() { cd.dispose(); } }; TestHelper.race(run, run); } }
@Override public void dispose() { if (disposed) { return; } List<Disposable> set; synchronized (this) { if (disposed) { return; } disposed = true; set = resources; resources = null; } dispose(set); }
ListCompositeDisposable implements Disposable, DisposableContainer { @Override public void dispose() { if (disposed) { return; } List<Disposable> set; synchronized (this) { if (disposed) { return; } disposed = true; set = resources; resources = null; } dispose(set); } }
ListCompositeDisposable implements Disposable, DisposableContainer { @Override public void dispose() { if (disposed) { return; } List<Disposable> set; synchronized (this) { if (disposed) { return; } disposed = true; set = resources; resources = null; } dispose(set); } ListCompositeDisposable();  ListCompositeDisposable(Disposable... resources);  ListCompositeDisposable(Iterable<? extends Disposable> resources); }
ListCompositeDisposable implements Disposable, DisposableContainer { @Override public void dispose() { if (disposed) { return; } List<Disposable> set; synchronized (this) { if (disposed) { return; } disposed = true; set = resources; resources = null; } dispose(set); } ListCompositeDisposable();  ListCompositeDisposable(Disposable... resources);  ListCompositeDisposable(Iterable<? extends Disposable> resources); @Override void dispose(); @Override boolean isDisposed(); @Override boolean add(Disposable d); boolean addAll(Disposable... ds); @Override boolean remove(Disposable d); @Override boolean delete(Disposable d); void clear(); }
ListCompositeDisposable implements Disposable, DisposableContainer { @Override public void dispose() { if (disposed) { return; } List<Disposable> set; synchronized (this) { if (disposed) { return; } disposed = true; set = resources; resources = null; } dispose(set); } ListCompositeDisposable();  ListCompositeDisposable(Disposable... resources);  ListCompositeDisposable(Iterable<? extends Disposable> resources); @Override void dispose(); @Override boolean isDisposed(); @Override boolean add(Disposable d); boolean addAll(Disposable... ds); @Override boolean remove(Disposable d); @Override boolean delete(Disposable d); void clear();  }