Create Observable using interval method in RxJava

Periodically generates an infinite, ever increasing numbers (of type Long). The intervalRangevariant generates a limited amount of such numbers.

Observable<Long> clock = Observable.interval(1, TimeUnit.SECONDS);

clock.subscribe(time -> {
    if (time % 2 == 0) {
        System.out.println("Tick");
    } else {
        System.out.println("Tock");
    }
});

References
https://github.com/ReactiveX/RxJava/wiki/Creating-Observables#interval
http://reactivex.io/documentation/operators/interval.html