咸糖 - 自律者自由

Recent content on 咸糖 - 自律者自由

马上订阅 咸糖 - 自律者自由 RSS 更新: https://vim0.com/index.xml

Akka 源码解析

2020年1月15日 17:26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 object Main1 extends App { val system = ActorSystem("HelloSystem") val jazzListener = system.actorOf(Props[Listener]) val musicListener = system.actorOf(Props[Listener]) system.eventStream.subscribe(jazzListener, classOf[Jazz]) // jazzListener 订阅 Jazz 事件 system.eventStream.subscribe(musicListener, classOf[AllKindsOfMusic]) // musicListener 订阅 AllKindsOfMusic 以及它的子类 事件 // 只有 musicListener 接收到这个事件 system.eventStream.publish(Electronic("Parov Stelar")) // jazzListener