AsyncTask ; doInbackground() not called after calling method onPreExecute()

前端 未结 4 1213
星月不相逢
星月不相逢 2021-02-01 03:34

I did added async library at my project and checked already, I don\'t know why code flow doesn\'t go in to asynctask

Code

public void doMysql()
{
    Log         


        
4条回答
  •  心在旅途
    2021-02-01 04:36

    Doing this not working for you?

    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    

    I was already doing this and the problem was still there, the problem was I was using AsyncTask to run long background tasks that do run forever, so the ThreadPoolExecutor's worker threads were already occupied.

    In my case AsyncTask.THREAD_POOL_EXECUTOR (use debugger to get your executor properties) was having the ff properties:

    maximumPoolSize = 3
    largetsPoolSize = 2
    corePoolSize =2 
    

    So disabling one of the long running asyncTasks made my doInBackground code to run but that is not the right solution.

    The right solution is I moved long running tasks into custom threads rather than using AsyncTask.

提交回复
热议问题