With the availability of android phones with multiple cores, how can application developers make sure that their application makes use of the additional processing power of those cores. From what I understand, the only thing that app developers can do is make their application multi-threaded and let android kernel take care of delegating the tasks on different cores.
I would like to know if there is anything else that can be done to optimize for multiple cores.Also, what are the best multi-threading practices in android.
Instead of trying to perform threading yourself its best to use built in paradigms such as AsyncTask.
If you want
//Sets up a thread pool where NUM_THREADS is the amount that can run at the same time
ExecutorService threadPool = null;
threadPool = Executors.newFixedThreadPool(NUM_THREADS);
//Will execute something on one of the threads queuing if necessary
threadPool.execute(new Runnable() {
@Override
public void run() {
}});
Typically web calls and data parsing should be done on a separate thread
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With