views:

38

answers:

2
  1. Is it a good solution or not?

  2. How to implement?

  3. When should I shutdown properly? I shutdown it onDestroy() in the Activity, then relaunch my app as soon as possible. It causes a java.util.concurrent.RejectedExecutionException, why? Does anyone know its lifecycle?

Any idea? Thanks.

A: 
Tony
Sorry about my typo, I mean onDestroy() in the Activity. I have no idea why I close the App (shutdown the Executor) and relaunch the app again, it got crash by the RejectedExecutionException. It seems to execute the task when it is not completely shutdown and use the old executor again. Why?
shiami
Maybe you can post some of your code on, so that we can know more about your question. BTW, I think it is better to create and shutdown Executor in Application object(like I said in my answer to your second question), since Executor is a heavy object, and user can launch and exit Activity very frequently, but Application object will be there unless the app process is killed. And if Executor is created in Activity, it is hard to reuse the Executor from outside of this Activity.
Tony
Thanks for the tip. I think that's why it can not use in the Activity's lifecycle.
shiami
A: 

I just figure out the AsyncYask already implemented the Java's concurrency executor with core_pool_size 5 and max_pool_size 128. That's great!

shiami