Guava EventBus dispatching

后端 未结 4 634
礼貌的吻别
礼貌的吻别 2021-02-07 16:35

I\'m using Guava\'s EventBus to kick off some processing and report results. Here\'s a very simple compilable example:

import com.google.common.eventbus.EventBu         


        
4条回答
  •  梦谈多话
    2021-02-07 17:14

    While posting to the EventBus does not return until all "subscribers" have been signaled .. those subscribers might NOT have begun execution. That means that when the first bus.post returns, you continue the next post without any intervening subscriber having begun to process.

    public void post(Object event) Posts an event to all registered subscribers. This method will return successfully after the event has been posted to all subscribers, and regardless of any exceptions thrown by subscribers. If no subscribers have been subscribed for event's class, and event is not already a DeadEvent, it will be wrapped in a DeadEvent and reposted.

    Parameters: event - event to post.

提交回复
热议问题