androidsynchronizationguavaandroid-guava

Guava EventBus and Singleton: Synchronization


I have a question regarding the principle of work of Guava EventBus. My objects are registered to EventBus. In 10 second time interval, message is sent to them, where processing is done and I compare some variable in object with singleton value.By some criteria, I change singleton value. I made some research in Guava documentation but I didn't find any information about synchronization issues.

Is this right way to do so?

With regards


Solution

  • As long as you use EventBus (rather than AsyncEventBus), there are no synchronization issues added by the bus. The event bus simply executes you subscribers immediately in the same thread.

    As long as you yourself stick with a single thread, there's no multithreading and no need for any synchronization.