开发者

Android: Identify what code an AsyncTask is running

开发者 https://www.devze.com 2023-04-08 20:38 出处:网络
开发者_StackOverflow社区In Eclipse in the Debug window I see a thread that shows: Thread <16> AsyncTask #11
开发者_StackOverflow社区

In Eclipse in the Debug window I see a thread that shows:

Thread <16> AsyncTask #11

Is there a way to determine what actual section of code the AsyncTask is referring to? Is there something I have to add in code to identify that running thread?


You can name the AsyncTask thread at the beginning of your doInBackground function:

public void doInBackground(Params... params) {
    Thread.currentThread().setName("Foo (AsyncTask)");
    // ... rest of your AsyncTask processing ...
}

The specified name will be shown in the Eclipse Debug window, as well as thread list in DDMS perspective.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号