@Test public void testTrampolineWorkerHandlesConcurrentScheduling() { final Worker trampolineWorker = Schedulers.trampoline().createWorker(); final Observer<Subscription> observer = Observers.empty(); final TestSubscriber<Subscription> ts = new TestSubscriber<Subscription>(observer); Observable.range(0, 50) .flatMap(new Func1<Integer, Observable<Subscription>>() { @Override public Observable<Subscription> call(Integer count) { return Observable.interval(1, TimeUnit.MICROSECONDS).map( new Func1<Long, Subscription>() { @Override public Subscription call(Long count) { return trampolineWorker.schedule(new Action0() { @Override public void call() {} }); } }).limit(100); } }) .subscribeOn(Schedulers.computation()) .subscribe(ts); ts.awaitTerminalEvent(); ts.assertNoErrors(); }
@Override public Worker createWorker() { return new InnerCurrentThreadScheduler(); }
TrampolineScheduler extends Scheduler { @Override public Worker createWorker() { return new InnerCurrentThreadScheduler(); } }
TrampolineScheduler extends Scheduler { @Override public Worker createWorker() { return new InnerCurrentThreadScheduler(); } TrampolineScheduler(); }
TrampolineScheduler extends Scheduler { @Override public Worker createWorker() { return new InnerCurrentThreadScheduler(); } TrampolineScheduler(); @Override Worker createWorker(); }
TrampolineScheduler extends Scheduler { @Override public Worker createWorker() { return new InnerCurrentThreadScheduler(); } TrampolineScheduler(); @Override Worker createWorker();  }