0
與reactor-core 1.1.4-RELEASE
我在下面嘗試,但沒有打印出來。我應該錯過什麼?反應堆根本沒有反應
Reactor reactor = Reactors.reactor(new Environment());
reactor.on(
$("hello"),
(Event<String> ev) -> System.out.println("hello "
+ ev.getData()));
reactor.notify("hello", Event.wrap("world"));
@EDIT
以下測試證實,接收器守護線程可以處理事件之前退出。
Reactor reactor = Reactors.reactor(new Environment());
reactor.on($("hello"), (Event<String> ev) -> {
System.out.println(Thread.currentThread().getName());
System.out.println(Thread.currentThread().isDaemon());
System.out.println("hello " + ev.getData());
});
reactor.notify("hello", Event.wrap("world"));
try {
Thread.sleep(1000);
} catch (Exception e) {
}