forked from PacktPublishing/Learning-RxJava-Second-Edition
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh8_15.java
More file actions
25 lines (22 loc) · 678 Bytes
/
Copy pathCh8_15.java
File metadata and controls
25 lines (22 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import java.util.concurrent.TimeUnit;
public class Ch8_15 {
public static void main(String[] args) {
Flowable.interval(1, TimeUnit.MILLISECONDS)
.onBackpressureLatest()
.observeOn(Schedulers.io())
.subscribe(i -> {
sleep(5);
System.out.println(i);
});
sleep(5000);
}
private static void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}