I will give you some information about thread pool implementation and method encapsulation library. I have a problem while developing Android application. I need to create AsyncTasks every network operation and I have a lots of this. So I create this library and solve the problem. With this library you can do your threading works easily and not need to create AsyncTask class more…
First part is pool implementation.
Firstly, you need to implement PoolHandler interface and make your configurations.
getPoolName(): This gives a name to pool which associated activity. Note: I recommend to give unique name to pool.
getAwaitMillisTime(): Await time before closing pool. If you give 0, the pool close immediately.
getThreadConfiguration(): This is your pool configuration same as standart ThreadPoolExecutor class.
After you need to create CachedThread instance. This instance use for open, execute and close pool. Now you can call your Callable or Runnable tasks.
Do not forget to close pool after your job finished!
Second part of the library is Method Encapsulation. I think this is most interesting part of the library. If you want to do threading work and you don’t need to create Callable or Runnable classes. Only you write your threading code into a method and mark this method with @AsyncMethod annotation. After that you can call this method in a thread and get results.
Firstly, create a AsyncMethodCaller instance and initialize it. While initializing, you need to set worker thread pool. You can use CachedThread implementation which talk about above. This initialization scan associated object methods and find marked methods.
Marked method have to be like this.
And finally you can call this methods.
You can find this library link at below. If you have any questions or idea, you can share me please.