我在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"));
@编辑
下面的测试确认接收器守护线程可以在处理事件之前退出。
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) {
}