You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Therefore, it must always be unique to each concurrent (or parallel) thread running the same method.
When does the value of the if statement become false in the above condition? Assuming it does become false, why doesn't this cause any race conditions? Given that there are no locks used, and it is also not an atomic variable.
The text was updated successfully, but these errors were encountered:
sreramk
changed the title
When does postingState.isPosting become false in the post(...) method?
When does postingState.isPosting become false in the post(Object event) method?
Jun 11, 2021
When does the value of the if statement become false in the above condition?
before the if statement isPosting will always be false. seems like a safeguard.
Assuming it does become false, why doesn't this cause any race conditions?
well it probably would cause race conditions in that case.
however, if you look at cancelEventDelivery you'll see this variable is used in order to ensure some preconditions. so it's not useless.
Thanks for clarifying. I was trying to understand the code and that part was confusing. Even if it does not have any performance impact, removing the condition statement (assuming there is no other reason for having it) could make that part less confusing.
Thanks for clarifying. I was trying to understand the code and that part was confusing. Even if it does not have any performance impact, removing the condition statement (assuming there is no other reason for having it) could make that part less confusing.
race condition will appear with shared variable ,but PostingThreadState variable is in ThreadLocal.so it is unique for every thread , not a shared variable.
so it won't cause race condition.
The variable
postingState
is local to the thread retrieving it.EventBus/EventBus/src/org/greenrobot/eventbus/EventBus.java
Line 260 in 1d99507
Therefore, it must always be unique to each concurrent (or parallel) thread running the same method.
When does the value of the
if
statement becomefalse
in the above condition? Assuming it does becomefalse
, why doesn't this cause any race conditions? Given that there are no locks used, and it is also not an atomic variable.The text was updated successfully, but these errors were encountered: