-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Periodic.java
32 lines (24 loc) · 889 Bytes
/
Periodic.java
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
26
27
28
29
30
31
32
package io.vertx.example.reactivex.scheduler.interval;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.vertx.core.Launcher;
import io.vertx.reactivex.core.AbstractVerticle;
import java.util.concurrent.TimeUnit;
/*
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class Periodic extends AbstractVerticle {
public static void main(String[] args) {
Launcher.executeCommand("run", Periodic.class.getName());
}
@Override
public void start() throws Exception {
//
Scheduler scheduler = io.vertx.reactivex.core.RxHelper.scheduler(vertx);
// Create a periodic event stream using Vertx scheduler
Flowable<Long> o = Flowable.interval(1000, TimeUnit.MILLISECONDS, scheduler);
o.subscribe(item -> {
System.out.println("Got item " + item + " on thread " + Thread.currentThread().getName());
});
}
}