Guava EventBus dispatching

后端 未结 4 1250
轻奢々
轻奢々 2021-02-07 16:30

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:15

    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.

提交回复
热议问题