英文:
Go like channels in Java
问题
我在6年后回到Java,之前一直在使用Go。我正在寻找一些与Go通道在某种程度上相似的模式或库,但是在Java中。
我的目标是创建一种服务,我可以向其中发送事件,并让代码的其他部分进行订阅。
我一直在研究Observables,但似乎你必须在初始时刻就知道所有的值。
英文:
I'm back to Java after 6 years of Go. I'm looking for some pattern or library that is somehow similar to Go channels but in Java.
My objective is to have some kind of service where I can emit events to and have other parts of my code subscribe.
I've been looking at Observables but it seems that you have to know all the values on the initial moment.
答案1
得分: 0
如果你的应用程序是基于Spring的,你可以使用Spring的事件(Events)。
否则,可以查看Guava的事件总线(EventBus)。
专注分享java语言的经验与见解,让所有开发者获益!
评论