首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > Java > 事件对火是用弱引用java异步事件机制

事件对火是用弱引用java异步事件机制

资 源 简 介

events-on-fire The repeated implementation of the listener pattern for Java is a boring task which cannot be easily abstracted. Events-On-Fire is a way to get rid of this. Events-On-Fire offers a simple mechanism to fire events across your application without the need for any configuration and without the danger of memory leaks. A simple example Imagine, you have some sort of mailbox that occasionally tends to receive mails and some narrators that like to read these mails. Object mailbox = new MyMailbox(); // my producerObject narrator1 = new MyNarrator(); // one of my consumersObject narrator2 = new MyNarrator(); // another one of my consumers First, implement an event handler in MyNarrator: @EventHandlerpublic void handleEvent(Mail someMail) { // do fancy stuff here} Then, bind the narrators to the mailbox: Events.bind(mailbox, narrator1);Events.bind(mailbox, narrator2);

相 关 资 源

您 可 能 感 兴 趣 的

同 类 别 推 荐

VIP VIP
0.210036s