Skip to content

Instantly share code, notes, and snippets.

@jwkidd3
Created January 18, 2017 21:25
Show Gist options
  • Save jwkidd3/6d37007adf2e9876a3c2ac193e193c22 to your computer and use it in GitHub Desktop.
Save jwkidd3/6d37007adf2e9876a3c2ac193e193c22 to your computer and use it in GitHub Desktop.
FutureTask<Integer> f = new FutureTask<Integer>(() -> {
Thread.sleep(2000);
return 21;
});
new Thread(f).start();
Observable<Integer> values = Observable.from(f);
Subscription subscription = values.subscribe(
v -> System.out.println("Received: " + v),
e -> System.out.println("Error: " + e),
() -> System.out.println("Completed")
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment