Name the Thread of an AsyncTask

前端 未结 2 1924
执念已碎
执念已碎 2020-12-17 08:10

Is it possible to give a name to an AsyncTask\'s background thread, as for normal Threads in Java:

Thread(Runnable target, String name) 

I

相关标签:
2条回答
  • 2020-12-17 08:57

    Try calling this from inside doInBackground():

    Thread.currentThread().setName("some custom name");
    
    0 讨论(0)
  • 2020-12-17 09:02

    Why can't you extend the AsyncTask I dont understand.

    I extend my AsyncTask thousand times with debugger shows me which AsyncTask is bitching.

    public class MyAsyncTask extends AsyncTask<Void, Void, Void>{
    }
    

    like so

    0 讨论(0)
提交回复
热议问题