AsyncSubject extends Subject<T> { @CheckReturnValue @NonNull public static <T> AsyncSubject<T> create() { return new AsyncSubject<T>(); } @SuppressWarnings("unchecked")  AsyncSubject(); @CheckReturnValue @NonNull static AsyncSubject<T> create(); @Override void onSubscribe(Disposable s); @Override void onNext(T t); @SuppressWarnings("unchecked") @Override void onError(Throwable t); @SuppressWarnings("unchecked") @Override void onComplete(); @Override boolean hasObservers(); @Override boolean hasThrowable(); @Override boolean hasComplete(); @Override Throwable getThrowable(); boolean hasValue(); @Nullable T getValue(); Object[] getValues(); T[] getValues(T[] array);  }
@Test public void cancelRace() { AsyncSubject<Object> p = AsyncSubject.create(); for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { final TestObserver<Object> to1 = p.test(); final TestObserver<Object> to2 = p.test(); Runnable r1 = new Runnable() { @Override public void run() { to1.cancel(); } }; Runnable r2 = new Runnable() { @Override public void run() { to2.cancel(); } }; TestHelper.race(r1, r2); } }