As shown below, I am creating Observables
. I would like to wait specific amount of time in seconds as shown in the code. therefore I used either delay or interval
o
You have to wait in the main method. Put Thread.sleep(10000)
at the very end of the main()
method so the Observable
has chance to run. RxJava threads are daemon threads that stop when the application thread falls out of the main()
method.
public static void main(String[] args) {
Observable.just("Hello World!", "Keep printing values!")
.zipWith(Observable.interval(0, 5, TimeUnit.SECONDS), (a, b) -> a)
.subscribe(v ->
System.out.println(Thread.currentThread() + ": " + v)
);
Thread.sleep(10000); // <-----------------------------------
}