Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to optimize android apps for multiple cores

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.

like image 651
Tushar Gupta Avatar asked Nov 04 '22 15:11

Tushar Gupta


1 Answers

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

like image 79
Mark Hetherington Avatar answered Nov 14 '22 23:11

Mark Hetherington