Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. Observable.defer(() -> {
  2. AtomicLong lastFinishTime = new AtomicLong(0);
  3. return Observable
  4. .interval(5, TimeUnit.SECONDS)
  5. .map(n -> System.currentTimeMillis())
  6. .doOnNext(t -> {
  7. if (t > lastFinishTime.get()) {
  8. task();
  9. lastFinishTime.set(System.currentTimeMillis());
  10. });
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement