Android two AsyncTasks serially or parallel execution? - The second is freezing but the result is ok

前端 未结 3 600
深忆病人
深忆病人 2020-12-31 06:15

I run two AsyncTask tasks in my Android application which are from the same class but with different parameters. For example:

new myAsynckTask(a,b,c).execute         


        
3条回答
  •  醉酒成梦
    2020-12-31 06:38

    UPDATE: copied from Android Developers and initiated by Yazazzello

    "This class was deprecated in API level 26.0.0-alpha1. Use AsyncTask directly."

    You should use this for parallel execution:

    AsyncTaskCompat.executeParallel(new AsyncTask() {
                    @Override
                    protected Data doInBackground(Param... params) {
                        return downloader.getData(params[0]);
                    }
    
                    @Override
                    protected void onPostExecute(Data response) {
                        processData(response);
                    }
    }, param);
    

提交回复
热议问题