Skip to content

Instantly share code, notes, and snippets.

@PaulWoitaschek
Created April 2, 2016 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulWoitaschek/80ef58d766935d0f340d9b2ce7213b31 to your computer and use it in GitHub Desktop.
Save PaulWoitaschek/80ef58d766935d0f340d9b2ce7213b31 to your computer and use it in GitHub Desktop.
Demonstrates .share() race condition
Observable<Integer> bomb = Observable.range(1, 1000000)
.share();
bomb.observeOn(Schedulers.io())
.reduce((first, second) -> first + second)
.subscribe(System.out::println);
bomb.observeOn(Schedulers.io())
.reduce((first, second) -> first + second)
.subscribe(System.out::println);
@PaulWoitaschek
Copy link
Author

Prints different values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment