public void post(Object event) {
PostingThreadState postingState = currentPostingThreadState.get();
List<Object> eventQueue = postingState.eventQueue;
eventQueue.add(event);
if (!postingState.isPosting) {
postingState.isMainThread = isMainThread();
postingState.isPosting = true;
if (postingState.canceled) {
throw new EventBusException("Internal error. Abort state was not reset");
}
try {
while (!eventQueue.isEmpty()) {
postSingleEvent(eventQueue.remove(0), postingState);
}
} finally {
postingState.isPosting = false;
postingState.isMainThread = false;
}
}
}
When one thread run post method , postingState while always be false, Is there any example can show the case that postState be false? eventQueue size while never more than one, so Why eventQueue is necessary?
post
method ,postingState
while always befalse
, Is there any example can show the case thatpostState
be false?eventQueue
size while never more than one, so WhyeventQueue
is necessary?