hehonghui / hehonghui/AndroidEventBus
ThreadMode.ASYNC executes in one thread only
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 390
- PR merge metrics
- No merged PRs in 30d
Description
Thanks for the great library! However something is bothering me. I am posting a message to three different methods, each has its own tag and they are set to ThreadMode.ASYNC. However they do not execute in parallel, but sequentially.
EventBus.getDefault().post(7, "test1");
EventBus.getDefault().post(7, "test2");
EventBus.getDefault().post(7, "test3");
@Subscriber(tag = "test1", mode = ThreadMode.ASYNC)
public void test1(int request){
...
}
...
Logcat:
04-21 23:15:19.835 E/test1﹕ Working on a task
04-21 23:15:20.936 E/test1﹕ Done -2134183543
04-21 23:15:20.936 E/test2﹕ Working on a task
04-21 23:15:22.247 E/test2﹕ Done -2134183543
04-21 23:15:22.247 E/test3﹕ Working on a task
04-21 23:15:23.058 E/test3﹕ Done -2134183543
Expected something like this:
04-21 1.1 E/test1﹕ Working on a task
04-21 1.2 E/test2﹕ Working on a task
04-21 1.3 E/test3﹕ Working on a task
04-21 2.1 E/test1﹕ Done -2134183543
04-21 2.3 E/test2﹕ Done -2134183543
04-21 2.7 E/test3﹕ Done -2134183543
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at EventBus.post and trace how ThreadMode.ASYNC dispatches the three tagged subscribers to its executor. Reproduce the issue with the three test1, test2, and test3 handlers; done means their work can overlap rather than always running sequentially, matching the concurrent timing shown in the report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100