Created
September 4, 2016 00:19
-
-
Save asarkar/5306c82fcf62f5b95ad723436d2ed5d1 to your computer and use it in GitHub Desktop.
Revisions
-
abhijitsarkar created this gist
Sep 4, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ ConnectableFlowable<Integer> pub = Flowable.range(1, 10000) .publish(); pub.debounce(1, SECONDS) .subscribeOn(computation()) .subscribe(new DefaultSubscriber<Integer>() { @Override public void onStart() { request(1); } @Override public void onComplete() { System.out.println("Done."); } @Override public void onError(Throwable e) { System.err.println("Oh shit!"); e.printStackTrace(); } @Override public void onNext(Integer integer) { System.out.println(String.format("slow: %d on thread: %s", integer, Thread.currentThread().getName())); request(1); } }); pub.subscribe(x -> System.out.println(String.format("fast: %d on thread: %s", x, Thread.currentThread().getName()))); pub.connect(); Thread.sleep(5 * 60 * 1000);