Guest User

Untitled

a guest
May 20th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import io.reactivex.Observable;
  2. import java.util.concurrent.TimeUnit;
  3.  
  4. public class Launcher {
  5. public static void main(String[] args) {
  6. Observable<Long> secondIntervals =
  7. Observable.interval(1, TimeUnit.SECONDS);
  8.  
  9. secondIntervals.subscribe(s -> System.out.println(s));
  10.  
  11. /* Hold main thread for 5 seconds
  12. so Observable above has chance to fire */
  13. sleep(5000);
  14. }
  15.  
  16. public static void sleep(long millis) {
  17. try {
  18. Thread.sleep(millis);
  19. } catch (InterruptedException e) {
  20. e.printStackTrace();
  21. }
  22. }
  23. }
Add Comment
Please, Sign In to add comment