Open vixtor opened 9 years ago
that's right, @vixtor 。all the message execute in a single thread when the thread mode is async.you can custom the async event handler like this :
public class ThreadPoolHandler implements EventHandler {
ExecutorService mExecutorService = Executors.newFixedThreadPool(3);
EventHandler mHandler = new DefaultEventHandler();
@Override
public void handleEvent(final Subscription subscription, final Object event) {
mExecutorService.submit(new Runnable() {
@Override
public void run() {
mHandler.handleEvent(subscription, event);
}
});
}
}
and then set async event handler with EventBus.getDefault().setAsyncEventHandeler(new ThreadPoolHandler());
Thank you, this worked perfectly. If I may suggest, you could add this in the next version as ThreadMode.THREADPOOL or something similar.
That's great advice. We will consider putting it into our next version. I am collecting apps which adopt AndroidEventBus and they will be put in readme.md. Would it be too much to ask you to share with us your App name and download link? Thank you!
2015-04-22 18:31 GMT+08:00 Viktor Kvaternjak notifications@github.com:
Thank you, this worked perfectly. If I may suggest, you could add this in the next version as ThreadMode.THREADPOOL or something similar.
— Reply to this email directly or view it on GitHub https://github.com/bboyfeiyu/AndroidEventBus/issues/11#issuecomment-95124473 .
Sure, I will send it once it is finished and published.
Thank you very much![?]
2015-04-23 4:23 GMT+08:00 Viktor Kvaternjak notifications@github.com:
Sure, I will send it once it is finished and published.
— Reply to this email directly or view it on GitHub https://github.com/bboyfeiyu/AndroidEventBus/issues/11#issuecomment-95324958 .
@vixtor hi,I am collecting apps which adopt AndroidEventBus and they will be put in readme.md. Would it be too much to ask you to share with us your App name and download link? Thank you!
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.
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