Search code examples
greenrobot-eventbusgreenrobot-eventbus-3.0

Background thread vs Async thread pool


I see from the GreenRobot EventBus documentation that with thread mode BACKGROUND a single background thread is used and with thread mode ASYNC a thread pool is used.

Anyone happen to know whether the background thread used by the BACKGROUND thread mode separate and distinct from the threads used by the ASYNC thread mode?

I ask because I want to use BACKGROUND thread mode for quick events (like local file access) and I want to use ASYNC thread mode for slow(er) events (like network calls)... and naturally I'd like it if BACKGROUND events were never waiting on ASYNC events to complete.


Solution

  • Got a response from the GreenRobot Team here as follows:

    Each has its own queue (AsyncPoster, BackgroundPoster) and both use the same cached thread pool ExecutorService. So yes, they should not block each other.

    However, if you always use ASYNC those will also not block each other as each will use its own thread (the docs even warn about too many concurrent threads).