Second AsyncTask not executing

后端 未结 5 488
暗喜
暗喜 2021-01-04 22:34

I have 2 AsyncTask, one which is creating a socket connections and anotherone that is transmitting objects using those sockets. my code is this:

try {
               


        
5条回答
  •  醉酒成梦
    2021-01-04 22:48

    I hated it when HONEY COMB changed the multiple AsyncTask execution from concurrent to sequential. So every time I execute an AsyncTask, I do something like this.

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        task.execute();
    }
    

    But the thread pool size is 5, if you add the sixth task, it will be added in a queue, and will not be executed until one of the 5 thread has finished.

提交回复
热议问题