1

i am a beginner of EventBus. I tried to understand the statement in documentation with my program. But it doesn't like what you said in the documentation.

Documentation as follows

...... For example if you post another event in an event handler with MAIN thread mode, the second event handler will finish before the first one (because it is called synchronously – compare it to a method call). ......

my code as follows:

@Subscribe(threadMode = ThreadMode.MAIN)
public void onMainOrderMsgEvent(MainOrderMsgEvent event) {
    EventBus.getDefault().post(new OtherMsgEvent("Other Msg"));
    Log.e(TAG, "onMainOrderMsgEvent: " + " finished");
}

@Subscribe(threadMode = ThreadMode.MAIN)
public void onOtherMsgEvent(OtherMsgEvent event) {
    Log.e(TAG, "onOtherMsgEvent: " + " finished");
}

it should be like this:

01-26 13:51:59.801 32643-32643/liufushihai.project.threadmode E/MainActivity: onOtherMsgEvent:  finished
01-26 13:51:59.801 32643-32643/liufushihai.project.threadmode E/MainActivity: onMainOrderMsgEvent:  finished

but the result as follows:

01-26 13:51:59.801 32643-32643/liufushihai.project.threadmode E/MainActivity: onMainOrderMsgEvent:  finished
01-26 13:51:59.801 32643-32643/liufushihai.project.threadmode E/MainActivity: onOtherMsgEvent:  finished

Do I understand correctly ? I’ll be appreciated to get a replay.

0 Answers0