如何针对多个核心优化Android应用程序

Tus*_*pta 5 optimization multithreading android

随着具有多个内核的Android手机的可用性,应用程序开发人员如何确保他们的应用程序利用这些内核的额外处理能力.根据我的理解,应用程序开发人员唯一能做的就是让他们的应用程序多线程,让android内核负责将任务委托给不同的核心.

我想知道是否还有其他任何东西可以用来优化多个内核.另外,什么是Android中最好的多线程实践.

Mar*_*ton 2

最好使用内置范例(例如 AsyncTask),而不是尝试自己执行线程。

如果你想

//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() {

                      }});
Run Code Online (Sandbox Code Playgroud)

通常网络调用和数据解析应该在单独的线程上完成